';
+ $label.= '
' . $langs->trans('Ref') . ': ' . $this->ref;
+
+ $link = '
';
+ $linkend='';
+
+ if ($withpicto)
+ {
+ $result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
+ if ($withpicto != 2) $result.=' ';
+ }
+ $result.= $link . $this->ref . $linkend;
+ return $result;
+ }
+
+ /**
+ * Retourne le libelle du status d'un user (actif, inactif)
+ *
+ * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @return string Label of status
+ */
+ function getLibStatut($mode=0)
+ {
+ return $this->LibStatut($this->status,$mode);
+ }
+
+ /**
+ * Renvoi le libelle d'un status donne
+ *
+ * @param int $status Id status
+ * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @return string Label of status
+ */
+ function LibStatut($status,$mode=0)
+ {
+ global $langs;
+
+ if ($mode == 0)
+ {
+ $prefix='';
+ if ($status == 1) return $langs->trans('Enabled');
+ if ($status == 0) return $langs->trans('Disabled');
+ }
+ if ($mode == 1)
+ {
+ if ($status == 1) return $langs->trans('Enabled');
+ if ($status == 0) return $langs->trans('Disabled');
+ }
+ if ($mode == 2)
+ {
+ if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
+ if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+ }
+ if ($mode == 3)
+ {
+ if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
+ if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
+ }
+ if ($mode == 4)
+ {
+ if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
+ if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+ }
+ if ($mode == 5)
+ {
+ if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
+ if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
+ }
+ }
+
+
+ /**
+ * Initialise object with example values
+ * Id must be 0 if object instance is a specimen
+ *
+ * @return void
+ */
+ public function initAsSpecimen()
+ {
+ $this->id = 0;
+
+ $this->fk_website = '';
+ $this->pageurl = '';
+ $this->title = '';
+ $this->description = '';
+ $this->keywords = '';
+ $this->content = '';
+ $this->status = '';
+ $this->date_creation = '';
+ $this->date_modification = '';
+ $this->tms = '';
+
+
+ }
+
+}
diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php
index a975bac297a..bfcdb9e0c85 100644
--- a/htdocs/websites/index.php
+++ b/htdocs/websites/index.php
@@ -64,6 +64,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0,
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
+require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
$langs->load("admin");
$langs->load("other");
@@ -71,13 +72,23 @@ $langs->load("website");
if (! $user->admin) accessforbidden();
-$action = GETPOST('action','alpha');
-
$conf->dol_hide_leftmenu = 1;
+$error=0;
+$website=GETPOST('website', 'alpha');
+$page=GETPOST('page', 'alpha');
+$action = GETPOST('action','alpha');
+
+if (GETPOST('preview')) $action='preview';
+if (GETPOST('editmeta')) { $action='editmeta'; }
+if (GETPOST('editmenu')) { $action='editmenu'; }
+if (GETPOST('editcontent')) { $action='editcontent'; }
+
+if (empty($action)) $action='preview';
+
-$website='website1';
$object=new Website($db);
+$objectpage=new WebsitePage($db);
/*
@@ -87,19 +98,43 @@ $object=new Website($db);
// Action mise a jour ou ajout d'une constante
if ($action == 'update')
{
-
+ $db->begin();
+ $object->fetch(0, $website);
- if (! $res > 0) $error++;
-
- if (! $error)
- {
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- }
- else
- {
- setEventMessages($langs->trans("Error"), null, 'errors');
- }
+ $objectpage->fk_website = $object->id;
+ $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
+
+ $res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl);
+
+ if ($res > 0)
+ {
+ $objectpage->title = GETPOST('WEBSITE_TITLE');
+ $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
+ $objectpage->keyword = GETPOST('WEBSITE_KEYWORD');
+
+ $res = $objectpage->update($user);
+ if (! $res > 0)
+ {
+ $error++;
+ setEventMessages($objectpage->error, $objectpage->errors, 'errors');
+ }
+
+ if (! $error)
+ {
+ $db->commit();
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ $action='';
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
}
@@ -109,26 +144,108 @@ if ($action == 'update')
* View
*/
-$_SESSION['website_mode'] = 'edit';
-
-
$form = new Form($db);
$help_url='';
llxHeader('', $langs->trans("WebsiteSetup"), $help_url);
-$style=' style="padding-top: 4px; padding-left: 10px; border-bottom: 1px solid #888; height: 20px; vertical-align: middle; margin-bottom: 5px;"';
+ print "\n".'