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');
88 public $type_container;
118 public $allowed_in_frames;
133 public $disable_waf =
'NOSCANAUDIOFORINJECTION,NOSCANIFRAMEFORINJECTION,NOSCANOBJECTFORINJECTION';
148 public $grabbed_from;
158 public $fk_user_creat;
163 public $fk_user_modif;
168 public $author_alias;
186 const STATUS_DRAFT = 0;
187 const STATUS_VALIDATED = 1;
218 public $fields = array(
219 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'index' => 1,
'position' => 1,
'comment' =>
'Id'),
220 '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'),
221 'aliasalt' => array(
'type' =>
'varchar(255)',
'label' =>
'AliasAlt',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'index' => 0,
'position' => 11,
'searchall' => 0,
'comment' =>
'Alias alternative of page'),
222 'type_container' => array(
'type' =>
'varchar(16)',
'label' =>
'Type',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'index' => 0,
'position' => 12,
'comment' =>
'Type of container'),
223 'title' => array(
'type' =>
'varchar(255)',
'label' =>
'Label',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'searchall' => 1,
'help' =>
'UseTextBetween5And70Chars'),
224 'description' => array(
'type' =>
'varchar(255)',
'label' =>
'Description',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'searchall' => 1),
225 '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"'),
226 'keywords' => array(
'type' =>
'varchar(255)',
'label' =>
'Keywords',
'enabled' => 1,
'visible' => 1,
'position' => 45,
'searchall' => 0),
227 'lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Lang',
'enabled' => 1,
'notnull' => -1,
'visible' => 1,
'position' => 45,
'searchall' => 0),
229 'fk_website' => array(
'type' =>
'integer',
'label' =>
'WebsiteId',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 40,
'searchall' => 0,
'foreignkey' =>
'websitepage.rowid'),
230 'fk_page' => array(
'type' =>
'integer',
'label' =>
'ParentPageId',
'enabled' => 1,
'visible' => 1,
'notnull' => -1,
'position' => 45,
'searchall' => 0,
'foreignkey' =>
'website.rowid'),
231 'allowed_in_frames' => array(
'type' =>
'integer',
'label' =>
'AllowedInFrames',
'enabled' => 1,
'visible' => -1,
'position' => 48,
'searchall' => 0,
'default' =>
'0'),
232 'htmlheader' => array(
'type' =>
'html',
'label' =>
'HtmlHeader',
'enabled' => 1,
'visible' => 0,
'position' => 50,
'searchall' => 0),
233 'content' => array(
'type' =>
'mediumtext',
'label' =>
'Content',
'enabled' => 1,
'visible' => 0,
'position' => 51,
'searchall' => 0),
234 'grabbed_from' => array(
'type' =>
'varchar(255)',
'label' =>
'GrabbedFrom',
'enabled' => 1,
'visible' => 1,
'index' => 1,
'position' => 400,
'comment' =>
'URL page content was grabbed from'),
235 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500),
236 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 501),
238 'fk_user_creat' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 510),
239 'author_alias' => array(
'type' =>
'varchar(64)',
'label' =>
'AuthorAlias',
'enabled' => 1,
'visible' => -1,
'index' => 0,
'position' => 511,
'comment' =>
'Author alias'),
240 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => -1,
'position' => 512),
242 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -1,
'index' => 1,
'position' => 1000,
'notnull' => -1),
243 'object_type' => array(
'type' =>
'varchar(255)',
'label' =>
'ObjectType',
'enabled' => 1,
'visible' => 0,
'position' => 46,
'searchall' => 0,
'help' =>
''),
244 'fk_object' => array(
'type' =>
'varchar(255)',
'label' =>
'ObjectId',
'enabled' => 1,
'visible' => 0,
'position' => 47,
'searchall' => 0,
'help' =>
''),
245 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 510),
267 public function create(
User $user, $notrigger = 0)
270 $this->keywords =
dol_trunc($this->keywords, 255,
'right',
'utf-8', 1);
271 if ($this->aliasalt) {
272 $this->aliasalt =
','.preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $this->aliasalt)).
',';
275 $this->pageurl = preg_replace(
'/[^a-z0-9\-\_]/i',
'', $this->pageurl);
276 $this->pageurl = preg_replace(
'/\-\-+/',
'-', $this->pageurl);
277 $this->pageurl = preg_replace(
'/^\-/',
'', $this->pageurl);
280 $this->lang = preg_replace(
'/[_-].*$/',
'', trim($this->lang));
283 $dataposted = trim($this->htmlheader);
284 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
285 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
288 if (!$user->hasRight(
'website',
'writephp')) {
293 $this->error =
'Error: you try to create a page with PHP content in HTML body without having permissions for that.';
294 $this->errors[] = $this->error;
303 $this->error =
'Error: you try to create a page with PHP content in HTML header without having permissions for that.';
304 $this->errors[] = $this->error;
325 public function fetch(
$id, $website_id =
null, $page =
null, $aliasalt =
null, $translationparentid = 0, $translationparentlang =
'')
331 $sql .=
" t.fk_website,";
332 $sql .=
' t.type_container,';
333 $sql .=
" t.pageurl,";
334 $sql .=
" t.aliasalt,";
336 $sql .=
" t.description,";
338 $sql .=
" t.keywords,";
339 $sql .=
" t.htmlheader,";
340 $sql .=
" t.content,";
342 $sql .=
" t.fk_page,";
343 $sql .=
" t.allowed_in_frames,";
344 $sql .=
" t.status,";
345 $sql .=
" t.grabbed_from,";
346 $sql .=
" t.date_creation,";
347 $sql .=
" t.tms as date_modification,";
348 $sql .=
" t.fk_user_creat,";
349 $sql .=
" t.author_alias,";
350 $sql .=
" t.fk_user_modif,";
351 $sql .=
" t.import_key,";
352 $sql .=
" t.object_type,";
353 $sql .=
" t.fk_object";
354 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
356 $sql .=
' WHERE 1 = 1';
358 $sql .=
' AND t.rowid = '.((int)
$id);
361 $sql .=
' AND t.rowid <> '.((int) abs(
$id));
363 if (
null !== $website_id) {
364 $sql .=
" AND t.fk_website = ".((int) $website_id);
368 $tmppage = explode(
'/', $page);
369 if (!empty($tmppage[1])) {
370 $pagetouse = $tmppage[1];
371 if (strlen($tmppage[0])) {
372 $langtouse = $tmppage[0];
375 $sql .=
" AND t.pageurl = '".$this->db->escape($pagetouse).
"'";
377 $sql .=
" AND t.lang = '".$this->db->escape($langtouse).
"'";
381 $sql .=
" AND (t.aliasalt LIKE '%,".$this->db->escape($this->db->escapeforlike($aliasalt)).
",%' OR t.aliasalt LIKE '%, ".$this->db->escape($this->db->escapeforlike($aliasalt)).
",%')";
383 if ($translationparentid && $translationparentlang) {
384 $sql .=
" AND t.fk_page = ".((int) $translationparentid);
385 $sql .=
" AND t.lang = '".$this->db->escape($translationparentlang).
"'";
389 $sql .= $this->db->plimit(1);
391 $resql = $this->db->query($sql);
393 $numrows = $this->db->num_rows($resql);
395 $obj = $this->db->fetch_object($resql);
397 $this->
id = $obj->rowid;
399 $this->fk_website = $obj->fk_website;
400 $this->type_container = $obj->type_container;
402 $this->pageurl = $obj->pageurl;
403 $this->
ref = $obj->pageurl;
404 $this->aliasalt = preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $obj->aliasalt));
406 $this->title = $obj->title;
408 $this->image = $obj->image;
409 $this->keywords = $obj->keywords;
410 $this->htmlheader = $obj->htmlheader;
411 $this->content = $obj->content;
412 $this->lang = $obj->lang;
413 $this->fk_page = $obj->fk_page;
414 $this->allowed_in_frames = $obj->allowed_in_frames;
415 $this->
status = $obj->status;
416 $this->grabbed_from = $obj->grabbed_from;
417 $this->date_creation = $this->db->jdate($obj->date_creation);
418 $this->date_modification = $this->db->jdate($obj->date_modification);
419 $this->fk_user_creat = $obj->fk_user_creat;
420 $this->author_alias = $obj->author_alias;
421 $this->fk_user_modif = $obj->fk_user_modif;
422 $this->import_key = $obj->import_key;
423 $this->object_type = $obj->object_type;
424 $this->fk_object = $obj->fk_object;
426 $this->db->free($resql);
434 $this->errors[] =
'Error '.$this->db->lasterror();
435 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
454 public function fetchAll($websiteid =
'', $sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
462 $sql .=
" t.fk_website,";
463 $sql .=
" t.type_container,";
464 $sql .=
" t.pageurl,";
465 $sql .=
" t.aliasalt,";
467 $sql .=
" t.description,";
469 $sql .=
" t.keywords,";
470 $sql .=
" t.htmlheader,";
471 $sql .=
" t.content,";
473 $sql .=
" t.fk_page,";
474 $sql .=
" t.allowed_in_frames,";
475 $sql .=
" t.status,";
476 $sql .=
" t.grabbed_from,";
477 $sql .=
" t.date_creation,";
478 $sql .=
" t.tms as date_modification,";
479 $sql .=
" t.fk_user_creat,";
480 $sql .=
" t.author_alias,";
481 $sql .=
" t.fk_user_modif,";
482 $sql .=
" t.import_key,";
483 $sql .=
" t.object_type,";
484 $sql .=
" t.fk_object";
485 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
486 if (!empty($websiteid)) {
487 $sql .=
' WHERE t.fk_website = '.((int) $websiteid);
491 if (is_array($filter)) {
494 if (count($filter) > 0) {
495 foreach ($filter as $key => $value) {
496 if ($key ==
't.rowid' || $key ==
'rowid' || $key ==
't.fk_website' || $key ==
'fk_website' || $key ==
'status' || $key ==
't.status') {
497 $sqlwhere[] = $key.
" = ".((int) $value);
498 } elseif ($key ==
'type_container' || $key ==
't.type_container') {
499 $sqlwhere[] = $key.
" = '".$this->db->escape($value).
"'";
500 } elseif ($key ==
'lang' || $key ==
't.lang') {
501 $listoflang = array();
503 foreach (explode(
',', $value) as $tmpvalue) {
504 if ($tmpvalue ==
'null') {
508 $listoflang[] =
"'".$this->db->escape(substr(str_replace(
"'",
'', $tmpvalue), 0, 2)).
"'";
510 $stringtouse = $this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $listoflang), 1).
")";
512 $stringtouse =
"(".$stringtouse.
" OR ".$this->db->sanitize($key).
" IS NULL)";
514 $sqlwhere[] = $stringtouse;
516 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($value).
"%'";
520 if (count($sqlwhere) > 0) {
521 if (!empty($websiteid)) {
522 $sql .=
" AND (".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
524 $sql .=
" WHERE ".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere);
532 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
534 $this->errors[] = $errormessage;
535 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
539 if (!empty($sortfield)) {
540 $sql .= $this->db->order($sortfield, $sortorder);
542 if (!empty($limit)) {
543 $sql .= $this->db->plimit($limit, $offset);
546 $resql = $this->db->query($sql);
548 $num = $this->db->num_rows($resql);
550 while ($obj = $this->db->fetch_object($resql)) {
553 $record->id = $obj->rowid;
554 $record->fk_website = $obj->fk_website;
555 $record->type_container = $obj->type_container;
556 $record->pageurl = $obj->pageurl;
557 $record->aliasalt = preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $obj->aliasalt));
558 $record->title = $obj->title;
559 $record->description = $obj->description;
560 $record->image = $obj->image;
561 $record->keywords = $obj->keywords;
562 $record->htmlheader = $obj->htmlheader;
563 $record->content = $obj->content;
564 $record->lang = $obj->lang;
565 $record->fk_page = $obj->fk_page;
566 $record->allowed_in_frames = $obj->allowed_in_frames;
567 $record->status = $obj->status;
568 $record->grabbed_from = $obj->grabbed_from;
569 $record->date_creation = $this->db->jdate($obj->date_creation);
570 $record->date_modification = $this->db->jdate($obj->date_modification);
571 $record->fk_user_creat = $obj->fk_user_creat;
572 $record->author_alias = $obj->author_alias;
573 $record->fk_user_modif = $obj->fk_user_modif;
574 $record->import_key = $obj->import_key;
575 $record->object_type = $obj->object_type;
576 $record->fk_object = $obj->fk_object;
578 $records[$record->id] = $record;
580 $this->db->free($resql);
584 $this->error =
'Error '.$this->db->lasterror();
585 $this->errors[] = $this->error;
586 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
601 public function countAll($websiteid, $filter =
'', $filtermode =
'AND')
607 $sql =
'SELECT COUNT(t.rowid) as nb';
608 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
609 $sql .=
' WHERE t.fk_website = '.((int) $websiteid);
612 if (is_array($filter)) {
615 if (count($filter) > 0) {
616 foreach ($filter as $key => $value) {
617 if ($key ==
't.rowid' || $key ==
'rowid' || $key ==
't.fk_website' || $key ==
'fk_website' || $key ==
'status' || $key ==
't.status') {
618 $sqlwhere[] = $key.
" = ".((int) $value);
619 } elseif ($key ==
'type_container' || $key ==
't.type_container') {
620 $sqlwhere[] = $key.
" = '".$this->db->escape($value).
"'";
621 } elseif ($key ==
'lang' || $key ==
't.lang') {
622 $listoflang = array();
624 foreach (explode(
',', $value) as $tmpvalue) {
625 if ($tmpvalue ==
'null') {
629 $listoflang[] =
"'".$this->db->escape(substr(str_replace(
"'",
'', $tmpvalue), 0, 2)).
"'";
631 $stringtouse = $this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $listoflang), 1).
")";
633 $stringtouse =
"(".$stringtouse.
" OR ".$this->db->sanitize($key).
" IS NULL)";
635 $sqlwhere[] = $stringtouse;
637 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($value).
"%'";
641 if (count($sqlwhere) > 0) {
642 if (!empty($websiteid)) {
643 $sql .=
" AND (".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
645 $sql .=
" WHERE ".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere);
653 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
655 $this->errors[] = $errormessage;
656 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
660 $resql = $this->db->query($sql);
662 $obj = $this->db->fetch_object($resql);
667 $this->db->free($resql);
671 $this->error =
'Error '.$this->db->lasterror();
672 $this->errors[] = $this->error;
673 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
686 public function update(
User $user, $notrigger = 0)
689 $this->keywords =
dol_trunc($this->keywords, 255,
'right',
'utf-8', 1);
690 if ($this->aliasalt) {
691 $this->aliasalt =
','.preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $this->aliasalt)).
',';
694 $this->pageurl = preg_replace(
'/[^a-z0-9\-\_]/i',
'', $this->pageurl);
695 $this->pageurl = preg_replace(
'/\-\-+/',
'-', $this->pageurl);
696 $this->pageurl = preg_replace(
'/^\-/',
'', $this->pageurl);
699 $this->lang = preg_replace(
'/[_-].*$/',
'', trim($this->lang));
701 if ($this->fk_page > 0) {
702 if (empty($this->lang)) {
703 $this->error =
"ErrorLanguageMandatoryIfPageSetAsTranslationOfAnother";
706 $tmppage =
new WebsitePage($this->db);
707 $tmppage->fetch((
int) $this->fk_page);
708 if ($tmppage->lang == $this->lang) {
709 $this->error =
"ErrorLanguageOfTranslatedPageIsSameThanThisPage";
724 public function delete(
User $user, $notrigger = 0)
732 foreach ($this->childtablesoncascade as $table) {
733 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$table;
734 $sql .=
" WHERE fk_website_page = ".(int) $this->
id;
736 $result = $this->db->query($sql);
739 $this->errors[] = $this->db->lasterror();
753 $websiteobj =
new Website($this->db);
754 $result = $websiteobj->fetch($this->fk_website);
757 global $dolibarr_main_data_root;
758 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websiteobj->ref;
760 $filealias = $pathofwebsite.
'/'.$this->pageurl.
'.php';
761 $filetpl = $pathofwebsite.
'/page'.$this->
id.
'.tpl.php';
766 $this->error = $websiteobj->error;
767 $this->errors = $websiteobj->errors;
791 public function createFromClone(
User $user, $fromid, $newref, $newlang =
'', $istranslation = 0, $newwebsite = 0, $newtitle =
'', $website =
null)
793 global $hookmanager, $langs;
803 if (empty($newref) && !empty($newtitle)) {
808 if (empty($newref)) {
809 $langs->load(
"errors");
810 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE"));
814 if ($istranslation) {
815 if (is_null($website)) {
816 $website =
new Website($this->db);
818 $website->fetch(
$object->fk_website);
820 if ($website->id != $newwebsite) {
821 $langs->load(
"errors");
822 $this->error = $langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation");
838 $object->fk_user_creat = $user->id;
843 if (!empty($newlang)) {
847 if ($istranslation) {
848 if ($website->lang == $newlang) {
858 if (!empty($newwebsite)) {
859 $object->fk_website = $newwebsite;
862 $object->status = self::STATUS_DRAFT;
865 $object->context[
'createfromclone'] =
'createfromclone';
866 $result =
$object->create($user);
870 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
873 if ($istranslation) {
874 if ($website->lang == $newlang) {
876 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = ".((int) $result).
" WHERE rowid = ".((int) $fromid);
878 $result = $this->db->query($sql);
881 $this->error = $this->db->lasterror();
886 unset(
$object->context[
'createfromclone']);
894 $this->db->rollback();
911 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $maxlen = 24, $morecss =
'')
914 global $dolibarr_main_authentication, $dolibarr_main_demo;
919 $label =
'<u>'.$langs->trans(
"Page").
'</u>';
921 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->
ref.
'<br>';
922 $label .=
'<b>'.$langs->trans(
'ID').
':</b> '.$this->
id.
'<br>';
923 $label .=
'<b>'.$langs->trans(
'Title').
':</b> '.$this->title.
'<br>';
924 $label .=
'<b>'.$langs->trans(
'Language').
':</b> '.$this->lang;
926 $url = DOL_URL_ROOT.
'/website/index.php?websiteid='.$this->fk_website.
'&pageid='.
$this->id;
929 if (empty($notooltip)) {
931 $label = $langs->trans(
"ShowMyObject");
932 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
934 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
935 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
937 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
940 $linkstart =
'<a href="'.$url.
'"';
941 $linkstart .= $linkclose.
'>';
946 $result .= $linkstart;
948 $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);
950 if ($withpicto != 2) {
951 $result .= $this->ref;
964 public function getLibStatut($mode = 0)
966 return $this->LibStatut($this->
status, $mode);
977 public function LibStatut($status, $mode = 0)
982 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
985 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Offline');
986 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Online');
987 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Offline');
988 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Online');
991 $statusType =
'status5';
992 if ($status == self::STATUS_VALIDATED) {
993 $statusType =
'status4';
996 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1009 public function setCategories($categories)
1011 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1021 public function initAsSpecimen()
1029 $this->fk_website = 0;
1030 $this->type_container =
'page';
1031 $this->pageurl =
'specimen';
1032 $this->aliasalt =
'specimenalt';
1033 $this->title =
'My Page';
1036 $this->keywords =
'keyword1, keyword2';
1037 $this->allowed_in_frames = 1;
1038 $this->htmlheader =
'';
1039 $this->content =
'<html><body>This is a html content</body></html>';
1040 $this->
status = self::STATUS_DRAFT;
1041 $this->grabbed_from =
'';
1042 $this->date_creation = $now - (24 * 30 * 3600);
1043 $this->date_modification = $now - (24 * 7 * 3600);
1044 $this->fk_user_creat = $user->id;
1045 $this->author_alias =
'mypublicpseudo';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.