Completed
Branch develop (4d8e5a)
by
unknown
42:25
created

WebsitePage::fetch()   C

Complexity

Conditions 9
Paths 55

Size

Total Lines 77

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
nc 55
nop 4
dl 0
loc 77
rs 6.9462
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) 2007-2012  Laurent Destailleur <[email protected]>
3
 * Copyright (C) 2014       Juanjo Menent       <[email protected]>
4
 * Copyright (C) 2015       Florian Henry       <[email protected]>
5
 * Copyright (C) 2015       Raphaël Doursenaud  <[email protected]>
6
 * Copyright (C) ---Put here your own copyright and developer email---
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
/**
23
 * \file    website/websitepage.class.php
24
 * \ingroup website
25
 * \brief   File for the CRUD class of websitepage (Create/Read/Update/Delete)
26
 */
27
28
// Put here all includes required by your class file
29
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
30
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
31
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
32
33
/**
34
 * Class Websitepage
35
 */
36
class WebsitePage extends CommonObject
37
{
38
	/**
39
	 * @var string Id to identify managed objects
40
	 */
41
	public $element = 'websitepage';
42
	/**
43
	 * @var string Name of table without prefix where object is stored
44
	 */
45
	public $table_element = 'website_page';
46
	/**
47
	 * @var string String with name of icon for websitepage. Must be the part after the 'object_' into object_myobject.png
48
	 */
49
	public $picto = 'label';
50
51
	/**
52
	 */
53
54
	public $fk_website;
55
	public $pageurl;
56
	public $aliasalt;
57
	public $type_container;
58
	public $title;
59
	public $description;
60
	public $keywords;
61
	public $htmlheader;
62
	public $content;
63
	public $grabbed_from;
64
	public $status;
65
	public $date_creation;
66
	public $date_modification;
67
68
69
	// BEGIN MODULEBUILDER PROPERTIES
70
	/**
71
     * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
72
     */
73
	public $fields=array(
74
	    'rowid'          =>array('type'=>'integer',      'label'=>'TechnicalID',      'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1,  'comment'=>'Id'),
75
		'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'),
76
		'aliasalt'       =>array('type'=>'varchar(255)', 'label'=>'AliasAlt',         'enabled'=>1, 'visible'=>1,  'notnull'=>1, 'index'=>0, 'position'=>11, 'searchall'=>0, 'comment'=>'Alias alternative of page'),
77
		'type_container' =>array('type'=>'varchar(16)',  'label'=>'Type',             'enabled'=>1, 'visible'=>1,  'notnull'=>1, 'index'=>0, 'position'=>12, 'comment'=>'Type of container'),
78
		'title'          =>array('type'=>'varchar(255)', 'label'=>'Label',            'enabled'=>1, 'visible'=>1,  'position'=>30,  'searchall'=>1),
79
	    'description'    =>array('type'=>'varchar(255)', 'label'=>'Description',      'enabled'=>1, 'visible'=>1,  'position'=>30,  'searchall'=>1),
80
	    'keywords'       =>array('type'=>'varchar(255)', 'label'=>'Keywords',         'enabled'=>1, 'visible'=>1,  'position'=>45,  'searchall'=>0),
81
		'lang'           =>array('type'=>'varchar(6)',   'label'=>'Lang',             'enabled'=>1, 'visible'=>1,  'position'=>45,  'searchall'=>0),
82
		//'status'        =>array('type'=>'integer',      'label'=>'Status',           'enabled'=>1, 'visible'=>1,  'index'=>true,   'position'=>1000),
83
	    'fk_website'     =>array('type'=>'integer',      'label'=>'WebsiteId',        'enabled'=>1, 'visible'=>1,  'notnull'=>1, 'position'=>40,  'searchall'=>0, 'foreignkey'=>'websitepage.rowid'),
84
	    'fk_page'        =>array('type'=>'integer',      'label'=>'ParentPageId',     'enabled'=>1, 'visible'=>1,  'notnull'=>-1, 'position'=>45,  'searchall'=>0, 'foreignkey'=>'website.rowid'),
85
	    'htmlheader'     =>array('type'=>'text',         'label'=>'HtmlHeader',       'enabled'=>1, 'visible'=>0,  'position'=>50,  'searchall'=>0),
86
	    'content'        =>array('type'=>'mediumtext',   'label'=>'Content',          'enabled'=>1, 'visible'=>0,  'position'=>51,  'searchall'=>0),
87
		'grabbed_from'   =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom',      'enabled'=>1, 'visible'=>1,  'index'=>1,   'position'=>400, 'comment'=>'URL page content was grabbed from'),
88
	    'date_creation'  =>array('type'=>'datetime',     'label'=>'DateCreation',     'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
89
		'tms'            =>array('type'=>'timestamp',    'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501),
90
		//'date_valid'    =>array('type'=>'datetime',     'label'=>'DateValidation',     'enabled'=>1, 'visible'=>-1, 'position'=>502),
91
		//'fk_user_creat' =>array('type'=>'integer',      'label'=>'UserAuthor',       'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510),
92
		//'fk_user_modif' =>array('type'=>'integer',      'label'=>'UserModif',        'enabled'=>1, 'visible'=>-1, 'position'=>511),
93
		//'fk_user_valid' =>array('type'=>'integer',      'label'=>'UserValidation',        'enabled'=>1, 'visible'=>-1, 'position'=>512),
94
		'import_key'     =>array('type'=>'varchar(14)',  'label'=>'ImportId',         'enabled'=>1, 'visible'=>-1,  'index'=>1,  'position'=>1000, 'notnull'=>-1),
95
	);
96
	// END MODULEBUILDER PROPERTIES
97
98
99
	/**
100
	 * Constructor
101
	 *
102
	 * @param DoliDb $db Database handler
103
	 */
104
	public function __construct(DoliDB $db)
105
	{
106
		$this->db = $db;
107
	}
108
109
	/**
110
	 * Create object into database
111
	 *
112
	 * @param  User $user      User that creates
113
	 * @param  bool $notrigger false=launch triggers after, true=disable triggers
114
	 * @return int             <0 if KO, Id of created object if OK
115
	 */
116
	public function create(User $user, $notrigger = false)
117
	{
118
		$this->description = dol_trunc($this->description, 255, 'right', 'utf-8', 1);
119
		$this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1);
120
		if ($this->aliasalt) $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).',';	// content in database must be ',xxx,...,yyy,'
121
122
		return $this->createCommon($user, $notrigger);
123
	}
124
125
	/**
126
	 * Load object in memory from the database
127
	 *
128
	 * @param int		$id				Id object.
129
	 * 									If this is 0, the value into $page will be used. If not found of $page not defined, the default page of website_id will be used or the first page found if not set.
130
	 * 									If value is < 0, we must exclude this ID.
131
	 * @param string	$website_id 	Web site id (page name must also be filled if this parameter is used)
132
	 * @param string	$page       	Page name (website id must also be filled if this parameter is used)
133
	 * @param string	$aliasalt		Alternative alias to search page (slow)
134
	 *
135
	 * @return int <0 if KO, 0 if not found, >0 if OK
136
	 */
137
	public function fetch($id, $website_id = null, $page = null, $aliasalt = null)
138
	{
139
		dol_syslog(__METHOD__, LOG_DEBUG);
140
141
		$sql = 'SELECT';
142
		$sql .= ' t.rowid,';
143
		$sql .= " t.fk_website,";
144
		$sql .= ' t.type_container,';
145
		$sql .= " t.pageurl,";
146
		$sql .= " t.aliasalt,";
147
		$sql .= " t.title,";
148
		$sql .= " t.description,";
149
		$sql .= " t.keywords,";
150
		$sql .= " t.htmlheader,";
151
		$sql .= " t.content,";
152
		$sql .= " t.lang,";
153
		$sql .= " t.fk_page,";
154
		$sql .= " t.status,";
155
		$sql .= " t.grabbed_from,";
156
		$sql .= " t.date_creation,";
157
		$sql .= " t.tms as date_modification";
158
		$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
159
		//$sql .= ' WHERE entity IN ('.getEntity('website').')';       // entity is on website level
160
		$sql .= ' WHERE 1 = 1';
161
		if ($id > 0)
162
		{
163
			$sql .= ' AND t.rowid = ' . $id;
164
		}
165
		else
166
		{
167
			if ($id < 0) $sql .= ' AND t.rowid <> ' . abs($id);
168
			if (null !== $website_id) {
169
			    $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'";
170
			    if ($page)		$sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'";
171
			    if ($aliasalt)	$sql .= " AND t.aliasalt LIKE '%," . $this->db->escape($aliasalt) . ",%'";
172
			}
173
		}
174
        $sql .= $this->db->plimit(1);
175
176
		$resql = $this->db->query($sql);
177
		if ($resql) {
178
			$numrows = $this->db->num_rows($resql);
179
			if ($numrows) {
180
				$obj = $this->db->fetch_object($resql);
181
182
				$this->id = $obj->rowid;
183
184
				$this->fk_website = $obj->fk_website;
185
				$this->type_container = $obj->type_container;
186
				$this->pageurl = $obj->pageurl;
187
				$this->aliasalt = preg_replace('/,+$/', '', preg_replace('/^,+/', '', $obj->aliasalt));
188
				$this->title = $obj->title;
189
				$this->description = $obj->description;
190
				$this->keywords = $obj->keywords;
191
				$this->htmlheader = $obj->htmlheader;
192
				$this->content = $obj->content;
193
				$this->lang = $obj->lang;
194
				$this->fk_page = $obj->fk_page;
195
				$this->status = $obj->status;
196
				$this->grabbed_from = $obj->grabbed_from;
197
				$this->date_creation = $this->db->jdate($obj->date_creation);
198
				$this->date_modification = $this->db->jdate($obj->date_modification);
199
			}
200
			$this->db->free($resql);
201
202
			if ($numrows) {
203
				return 1;
204
			} else {
205
				return 0;
206
			}
207
		} else {
208
			$this->errors[] = 'Error ' . $this->db->lasterror();
209
			dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
210
211
			return - 1;
212
		}
213
	}
214
215
	/**
216
	 * Load object in memory from the database
217
	 *
218
	 * @param  string      $websiteid    Web site
219
	 * @param  string      $sortorder    Sort Order
220
	 * @param  string      $sortfield    Sort field
221
	 * @param  int         $limit        limit
222
	 * @param  int         $offset       Offset
223
	 * @param  array       $filter       Filter array
224
	 * @param  string      $filtermode   Filter mode (AND or OR)
225
	 * @return array|int                 int <0 if KO, array of pages if OK
226
	 */
227
	public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
228
	{
229
		dol_syslog(__METHOD__, LOG_DEBUG);
230
231
		$records=array();
232
233
		$sql = 'SELECT';
234
		$sql .= ' t.rowid,';
235
		$sql .= " t.fk_website,";
236
		$sql .= " t.type_container,";
237
		$sql .= " t.pageurl,";
238
		$sql .= " t.aliasalt,";
239
		$sql .= " t.title,";
240
		$sql .= " t.description,";
241
		$sql .= " t.keywords,";
242
		$sql .= " t.htmlheader,";
243
		$sql .= " t.content,";
244
		$sql .= " t.lang,";
245
		$sql .= " t.fk_page,";
246
		$sql .= " t.status,";
247
		$sql .= " t.grabbed_from,";
248
		$sql .= " t.date_creation,";
249
		$sql .= " t.tms as date_modification";
250
		$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
251
		$sql .= ' WHERE t.fk_website = '.$websiteid;
252
		// Manage filter
253
		$sqlwhere = array();
254
		if (count($filter) > 0) {
255
			foreach ($filter as $key => $value) {
256
				if ($key=='t.rowid' || $key=='t.fk_website') {
257
					$sqlwhere[] = $key . '='. $value;
258
				} else {
259
					$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
260
				}
261
			}
262
		}
263
		if (count($sqlwhere) > 0) {
264
			$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
265
		}
266
267
		if (!empty($sortfield)) {
268
			$sql .= $this->db->order($sortfield,$sortorder);
269
		}
270
		if (!empty($limit)) {
271
            $sql .=  ' ' . $this->db->plimit($limit, $offset);
272
		}
273
274
		$resql = $this->db->query($sql);
275
		if ($resql) {
276
			$num = $this->db->num_rows($resql);
277
278
			while ($obj = $this->db->fetch_object($resql))
279
			{
280
				$record = new self($this->db);
281
282
				$record->id = $obj->rowid;
283
				$record->fk_website = $obj->fk_website;
284
				$record->type_container = $obj->type_container;
285
				$record->pageurl = $obj->pageurl;
286
				$record->aliasalt = preg_replace('/,+$/', '', preg_replace('/^,+/', '', $obj->aliasalt));
287
				$record->title = $obj->title;
288
				$record->description = $obj->description;
289
				$record->keywords = $obj->keywords;
290
				$record->htmlheader = $obj->htmlheader;
291
				$record->content = $obj->content;
292
				$record->lang = $obj->lang;
293
				$record->fk_page = $obj->fk_page;
294
				$record->status = $obj->status;
295
				$record->grabbed_from = $obj->grabbed_from;
296
				$record->date_creation = $this->db->jdate($obj->date_creation);
297
				$record->date_modification = $this->db->jdate($obj->date_modification);
298
				//var_dump($record->id);
299
				$records[$record->id] = $record;
300
			}
301
			$this->db->free($resql);
302
303
			return $records;
304
		} else {
305
			$this->errors[] = 'Error ' . $this->db->lasterror();
306
			dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
307
308
			return -1;
309
		}
310
	}
311
312
	/**
313
	 * Update object into database
314
	 *
315
	 * @param  User $user      User that modifies
316
	 * @param  bool $notrigger false=launch triggers after, true=disable triggers
317
	 * @return int             <0 if KO, >0 if OK
318
	 */
319
	public function update(User $user, $notrigger = false)
320
	{
321
		$this->description = dol_trunc($this->description, 255, 'right', 'utf-8', 1);
322
		$this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1);
323
		if ($this->aliasalt) $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).',';	// content in database must be ',xxx,...,yyy,'
324
325
		return $this->updateCommon($user, $notrigger);
326
	}
327
328
	/**
329
	 * Delete object in database
330
	 *
331
	 * @param User $user       User that deletes
332
	 * @param bool $notrigger  false=launch triggers after, true=disable triggers
333
	 * @return int             <0 if KO, >0 if OK
334
	 */
335
	public function delete(User $user, $notrigger = false)
336
	{
337
		$result = $this->deleteCommon($user, $trigger);
0 ignored issues
show
Bug introduced by
The variable $trigger does not exist. Did you mean $notrigger?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
338
339
		if ($result > 0)
340
		{
341
			$websiteobj=new Website($this->db);
342
			$result = $websiteobj->fetch($this->fk_website);
343
344
			if ($result > 0)
345
			{
346
				global $dolibarr_main_data_root;
347
				$pathofwebsite=$dolibarr_main_data_root.'/website/'.$websiteobj->ref;
348
349
				$filealias=$pathofwebsite.'/'.$this->pageurl.'.php';
350
				$filetpl=$pathofwebsite.'/page'.$this->id.'.tpl.php';
351
352
				dol_delete_file($filealias);
353
				dol_delete_file($filetpl);
354
			}
355
		}
356
357
		return $result;
358
	}
359
360
	/**
361
	 * Load an object from its id and create a new one in database
362
	 *
363
	 * @param	User	$user				User making the clone
364
	 * @param 	int 	$fromid 			Id of object to clone
365
	 * @param	string	$newref				New ref/alias of page
366
	 * @param	string	$newlang			New language
367
	 * @param	int		$istranslation		1=New page is a translation of the cloned page.
368
	 * @param	int		$newwebsite			0=Same web site, >0=Id of new website
369
	 * @param	int		$keeptitleunchanged	1=Keep title unchanged
370
	 * @return 	mixed 						New object created, <0 if KO
371
	 */
372
	public function createFromClone(User $user, $fromid, $newref, $newlang='', $istranslation=0, $newwebsite=0, $keeptitleunchanged=0)
373
	{
374
		global $hookmanager, $langs;
375
		$error = 0;
376
377
		dol_syslog(__METHOD__, LOG_DEBUG);
378
379
		$object = new self($this->db);
380
381
		$this->db->begin();
382
383
		// Load source object
384
		$object->fetch($fromid);
385
		// Reset object
386
		$object->id = 0;
387
388
		// Clear fields
389
		$object->ref = $newref;
390
		$object->pageurl = $newref;
391
		$object->aliasalt = '';
392
		$object->title = ($keeptitleunchanged ? '' : $langs->trans("CopyOf").' ').$object->title;
393
		if (! empty($newlang)) $object->lang=$newlang;
394
		if ($istranslation) $object->fk_page = $fromid;
395
		else $object->fk_page = 0;
396
		if (! empty($newwebsite)) $object->fk_website=$newwebsite;
397
398
		// Create clone
399
		$object->context['createfromclone'] = 'createfromclone';
400
		$result = $object->create($user);
401
		if ($result < 0) {
402
			$error++;
403
			$this->error = $object->error;
404
			$this->errors = $object->errors;
405
			dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
406
		}
407
408
		// End
409
		if (!$error) {
410
			$this->db->commit();
411
412
			return $object;
413
		} else {
414
			$this->db->rollback();
415
416
			return -1;
417
		}
418
	}
419
420
	/**
421
	 *  Return a link to the user card (with optionaly the picto)
422
	 * 	Use this->id,this->lastname, this->firstname
423
	 *
424
	 *	@param	int		$withpicto			Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
425
	 *	@param	string	$option				On what the link point to
426
     *  @param	integer	$notooltip			1=Disable tooltip
427
     *  @param	int		$maxlen				Max length of visible user name
428
     *  @param  string  $morecss            Add more css on link
429
	 *	@return	string						String with URL
430
	 */
431
	function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
432
	{
433
		global $langs, $conf, $db;
434
        global $dolibarr_main_authentication, $dolibarr_main_demo;
435
        global $menumanager;
436
437
        $result = '';
438
        $companylink = '';
439
440
        $label = '<u>' . $langs->trans("Page") . '</u>';
441
        $label.= '<div width="100%">';
442
        $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
443
444
        $linkstart = '<a href="'.DOL_URL_ROOT.'/website/card.php?id='.$this->id.'"';
445
        $linkstart.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
446
        $linkstart.= '>';
447
		$linkend='</a>';
448
449
		$linkstart = $linkend = '';
450
451
        if ($withpicto)
452
        {
453
            $result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend);
454
        	if ($withpicto != 2) $result.=' ';
455
		}
456
		$result.= $linkstart . $this->ref . $linkend;
457
		return $result;
458
	}
459
460
	/**
461
	 *  Retourne le libelle du status d'un user (actif, inactif)
462
	 *
463
	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
464
	 *  @return	string 			       Label of status
465
	 */
466
	function getLibStatut($mode=0)
467
	{
468
		return $this->LibStatut($this->status,$mode);
469
	}
470
471
	/**
472
	 *  Renvoi le libelle d'un status donne
473
	 *
474
	 *  @param	int		$status        	Id status
475
	 *  @param  int		$mode          	0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
476
	 *  @return string 			       	Label of status
477
	 */
478
	function LibStatut($status,$mode=0)
479
	{
480
		global $langs;
481
482
		if ($mode == 0)
483
		{
484
			$prefix='';
485
			if ($status == 1) return $langs->trans('Enabled');
486
			if ($status == 0) return $langs->trans('Disabled');
487
		}
488
		if ($mode == 1)
489
		{
490
			if ($status == 1) return $langs->trans('Enabled');
491
			if ($status == 0) return $langs->trans('Disabled');
492
		}
493
		if ($mode == 2)
494
		{
495
			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
496
			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
497
		}
498
		if ($mode == 3)
499
		{
500
			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
501
			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
502
		}
503
		if ($mode == 4)
504
		{
505
			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
506
			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
507
		}
508
		if ($mode == 5)
509
		{
510
			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
511
			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
512
		}
513
	}
514
515
516
	/**
517
	 * Initialise object with example values
518
	 * Id must be 0 if object instance is a specimen
519
	 *
520
	 * @return void
521
	 */
522
	public function initAsSpecimen()
523
	{
524
		$this->id = 0;
525
526
		$now=dol_now();
527
528
		$this->fk_website = '';
529
		$this->type_container = 'page';
530
		$this->pageurl = 'specimen';
531
		$this->aliasalt = 'specimenalt';
532
		$this->title = 'My Page';
533
		$this->description = 'This is my page';
534
		$this->keywords = 'keyword1, keyword2';
535
		$this->htmlheader = '';
536
		$this->content = '<html><body>This is a html content</body></html>';
537
		$this->status = '';
538
		$this->grabbed_from = '';
539
		$this->date_creation = $now - (24 * 30 * 3600);
540
		$this->date_modification = $now - (24 * 7 * 3600);
541
	}
542
543
}
544