dolibarr  9.0.0
website.inc.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * or see http://www.gnu.org/
17 */
18 
26 // Load website class
27 include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
28 // Define $website
29 if (! is_object($website))
30 {
31  $website=new Website($db);
32  $website->fetch(0,$websitekey);
33 }
34 // Define $weblangs
35 if (! is_object($weblangs))
36 {
37  $weblangs = dol_clone($langs); // TODO Use an object lang from a language set into $website object instead of backoffice
38 }
39 // Define $websitepage if we have $websitepagefile defined
40 if (! $pageid && ! empty($websitepagefile))
41 {
42  $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile));
43 }
44 if ($pageid > 0)
45 {
46  include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
47  $websitepage=new WebsitePage($db);
48  $websitepage->fetch($pageid);
49 }
50 
51 // A lang was forced, so we change weblangs init
52 if (GETPOST('l','aZ09')) $weblangs->setDefaultLang(GETPOST('l','aZ09'));
53 // A lang was forced, so we check to find if we must make a redirect on translation page
54 if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') // If we browsing page using Dolibarr server or a Native web server
55 {
56  //print_r(get_defined_constants(true));exit;
57  if (GETPOST('l','aZ09'))
58  {
59  $sql ="SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page";
60  $sql.=" FROM ".MAIN_DB_PREFIX."website_page as wp";
61  $sql.=" WHERE wp.fk_website = ".$website->id;
62  $sql.=" AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid;
63  if (is_object($websitepage) && $websitepage->fk_page > 0) $sql.=" OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page;
64  $sql.=")";
65  $sql.= " AND wp.lang = '".$db->escape(GETPOST('l','aZ09'))."'";
66 
67  $resql = $db->query($sql);
68  if ($resql)
69  {
70  $obj = $db->fetch_object($resql);
71  if ($obj)
72  {
73  $newpageid = $obj->rowid;
74  if ($newpageid != $pageid) // To avoid to make a redirect on same page (infinite loop)
75  {
76  if (defined('USEDOLIBARRSERVER')) {
77  header("Location: ".DOL_URL_ROOT.'/public/website/index.php?website='.$websitekey.'&pageid='.$newpageid.'&l='.GETPOST('l','aZ09'));
78  exit;
79  }
80  else
81  {
82  $newpageref = $obj->pageurl;
83  header("Location: ".$newpageref.'.php?l='.GETPOST('l','aZ09'));
84  exit;
85  }
86  }
87  }
88  }
89  }
90 }
91 
92 // Load websitepage class
93 include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
Class Website.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
Class Websitepage.