--- /tmp/dsg/dolibarr/htdocs/website/class/github_19.0.3_website.class.php
+++ /tmp/dsg/dolibarr/htdocs/website/class/client_website.class.php
@@ -33 +32,0 @@
-
@@ -50,2 +49 @@
- * @var int Does this object support multicompany module ?
- * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
+ * @var array Does website support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
@@ -55,4 +52,0 @@
-
- protected $childtablesoncascade = array();
-
-
@@ -95 +89 @@
- * @var integer date_creation
+ * @var integer|string date_creation
@@ -100 +94 @@
- * @var integer date_modification
+ * @var integer|string date_modification
@@ -103,7 +97,3 @@
- /**
- * @var integer date_modification
- */
- public $tms;
-
- /**
- * @var integer Default home page
+
+ /**
+ * @var integer
@@ -112,4 +101,0 @@
-
- /**
- * @var int User Create Id
- */
@@ -119,6 +105 @@
- * @var int User Modification Id
- */
- public $fk_user_modif;
-
- /**
- * @var string Virtual host
+ * @var string
@@ -129 +110 @@
- * @var int Use a manifest file
+ * @var int
@@ -134,6 +115,3 @@
- * @var int Postion
- */
- public $position;
-
- /**
- * @var array List of containers
+ * List of containers
+ *
+ * @var array
@@ -155,0 +134 @@
+ return 1;
@@ -161,4 +140,4 @@
- * @param User $user User that creates
- * @param bool $notrigger false=launch triggers after, true=disable triggers
- *
- * @return int Return integer <0 if KO, 0 if already exists, ID of created object if OK
+ * @param User $user User that creates
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ *
+ * @return int <0 if KO, Id of created object if OK
@@ -177 +156 @@
- $this->entity = (int) $this->entity;
+ $this->entity = (int) $this->entity;
@@ -180 +159 @@
- $this->ref = trim($this->ref);
+ $this->ref = trim($this->ref);
@@ -183 +162 @@
- $this->description = trim($this->description);
+ $this->description = trim($this->description);
@@ -186,11 +165,11 @@
- $this->status = (int) $this->status;
- }
- if (empty($this->date_creation)) {
- $this->date_creation = $now;
- }
- if (empty($this->date_modification)) {
- $this->date_modification = $now;
- }
- // Remove spaces and be sure we have main language only
- $this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en
- $tmparray = explode(',', $this->otherlang);
+ $this->status = (int) $this->status;
+ }
+ if (empty($this->date_creation)) {
+ $this->date_creation = $now;
+ }
+ if (empty($this->date_modification)) {
+ $this->date_modification = $now;
+ }
+ // Remove spaces and be sure we have main language only
+ $this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en
+ $tmparray = explode(',', $this->otherlang);
@@ -199,5 +177,0 @@
- // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,'
- if (empty(trim($val))) {
- unset($tmparray[$key]);
- continue;
- }
@@ -209,8 +183,8 @@
- // Check parameters
- if (empty($this->entity)) {
- $this->entity = $conf->entity;
- }
- if (empty($this->lang)) {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MainLanguage"));
- return -1;
- }
+ // Check parameters
+ if (empty($this->entity)) {
+ $this->entity = $conf->entity;
+ }
+ if (empty($this->lang)) {
+ $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MainLanguage"));
+ return -1;
+ }
@@ -230 +203,0 @@
- $sql .= 'position,';
@@ -243 +215,0 @@
- $sql .= ' '.((int) $this->position).",";
@@ -259 +231 @@
- // Create a subdirectory for each language (except main language)
+ // Create subdirectory per language
@@ -264,4 +236,2 @@
- if (trim($val) == $this->lang) {
- continue;
- }
- dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val), DOL_DATA_ROOT);
+ if (trim($val) == $this->lang) continue;
+ dol_mkdir($conf->website->dir_output.'/'.$this->ref.'/'.trim($val));
@@ -271,21 +241,17 @@
- // Create subdirectory for images and js
- dol_mkdir($conf->medias->multidir_output[$conf->entity].'/image/'.$this->ref, DOL_DATA_ROOT);
- dol_mkdir($conf->medias->multidir_output[$conf->entity].'/js/'.$this->ref, DOL_DATA_ROOT);
-
- // Uncomment this and change WEBSITE to your own tag if you
- // want this action to call a trigger.
- // if (!$notrigger) {
-
- // // Call triggers
- // $result = $this->call_trigger('WEBSITE_CREATE',$user);
- // if ($result < 0) $error++;
- // // End call triggers
- // }
- }
-
- if (!$error) {
- $stringtodolibarrfile = "# Some properties for Dolibarr web site CMS\n";
- $stringtodolibarrfile .= "param=value\n";
- //print $conf->website->dir_output.'/'.$this->ref.'/.dolibarr';exit;
- file_put_contents($conf->website->dir_output.'/'.$this->ref.'/.dolibarr', $stringtodolibarrfile);
- }
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action to call a trigger.
+ // if (!$notrigger) {
+
+ // // Call triggers
+ // $result = $this->call_trigger('MYOBJECT_CREATE',$user);
+ // if ($result < 0) $error++;
+ // // End call triggers
+ // }
+ }
+
+ if (! $error) {
+ $stringtodolibarrfile = "# Some properties for Dolibarr web site CMS\n";
+ $stringtodolibarrfile .= "param=value\n";
+ //print $conf->website->dir_output.'/'.$this->ref.'/.dolibarr';exit;
+ file_put_contents($conf->website->dir_output.'/'.$this->ref.'/.dolibarr', $stringtodolibarrfile);
+ }
@@ -296,5 +262,2 @@
- if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
- return 0;
- } else {
- return -1 * $error;
- }
+
+ return -1 * $error;
@@ -313 +276 @@
- * @return int Return integer <0 if KO, 0 if not found, >0 if OK
+ * @return int <0 if KO, 0 if not found, >0 if OK
@@ -319,2 +282,2 @@
- $sql = "SELECT";
- $sql .= " t.rowid,";
+ $sql = 'SELECT';
+ $sql .= ' t.rowid,';
@@ -323 +285,0 @@
- $sql .= " t.position,";
@@ -335,2 +297,2 @@
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
- $sql .= " WHERE t.entity IN (".getEntity('website').")";
+ $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql .= ' WHERE t.entity IN ('.getEntity('website').')';
@@ -340 +302 @@
- $sql .= " AND t.rowid = ".(int) $id;
+ $sql .= ' AND t.rowid = '.(int) $id;
@@ -353 +314,0 @@
- $this->position = $obj->position;
@@ -389 +350 @@
- * @return int Return integer <0 if KO, 0 if not found, >0 if OK
+ * @return int <0 if KO, 0 if not found, >0 if OK
@@ -404,7 +365,8 @@
- * @param string $sortorder Sort Order
- * @param string $sortfield Sort field
- * @param int $limit offset limit
- * @param int $offset offset limit
- * @param array $filter filter array
- * @param string $filtermode filter mode (AND or OR)
- * @return array|int int <0 if KO, array of pages if OK
+ * @param string $sortorder Sort Order
+ * @param string $sortfield Sort field
+ * @param int $limit offset limit
+ * @param int $offset offset limit
+ * @param array $filter filter array
+ * @param string $filtermode filter mode (AND or OR)
+ *
+ * @return int <0 if KO, >0 if OK
@@ -416,4 +378,2 @@
- $records = array();
-
- $sql = "SELECT";
- $sql .= " t.rowid,";
+ $sql = 'SELECT';
+ $sql .= ' t.rowid,';
@@ -432,2 +392,2 @@
- $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
- $sql .= " WHERE t.entity IN (".getEntity('website').")";
+ $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql .= ' WHERE t.entity IN ('.getEntity('website').')';
@@ -438 +398 @@
- $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
+ $sqlwhere [] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
@@ -442 +402 @@
- $sql .= ' AND '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere);
+ $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
@@ -449,2 +409,3 @@
- $sql .= $this->db->plimit($limit, $offset);
- }
+ $sql .= ' '.$this->db->plimit($limit, $offset);
+ }
+ $this->records = array();
@@ -457,18 +418,18 @@
- $record = new self($this->db);
-
- $record->id = $obj->rowid;
-
- $record->entity = $obj->entity;
- $record->ref = $obj->ref;
- $record->description = $obj->description;
- $record->lang = $obj->lang;
- $record->otherlang = $obj->otherlang;
- $record->status = $obj->status;
- $record->fk_default_home = $obj->fk_default_home;
- $record->virtualhost = $obj->virtualhost;
- $record->fk_user_creat = $obj->fk_user_creat;
- $record->fk_user_modif = $obj->fk_user_modif;
- $record->date_creation = $this->db->jdate($obj->date_creation);
- $record->date_modification = $this->db->jdate($obj->date_modification);
-
- $records[$record->id] = $record;
+ $line = new self($this->db);
+
+ $line->id = $obj->rowid;
+
+ $line->entity = $obj->entity;
+ $line->ref = $obj->ref;
+ $line->description = $obj->description;
+ $line->lang = $obj->lang;
+ $line->otherlang = $obj->otherlang;
+ $line->status = $obj->status;
+ $line->fk_default_home = $obj->fk_default_home;
+ $line->virtualhost = $obj->virtualhost;
+ $this->fk_user_creat = $obj->fk_user_creat;
+ $this->fk_user_modif = $obj->fk_user_modif;
+ $line->date_creation = $this->db->jdate($obj->date_creation);
+ $line->date_modification = $this->db->jdate($obj->date_modification);
+
+ $this->records[$line->id] = $line;
@@ -478 +439 @@
- return $records;
+ return $num;
@@ -493 +454 @@
- * @return int Return integer <0 if KO, >0 if OK
+ * @return int <0 if KO, >0 if OK
@@ -506 +467 @@
- $this->entity = (int) $this->entity;
+ $this->entity = (int) $this->entity;
@@ -509 +470 @@
- $this->ref = trim($this->ref);
+ $this->ref = trim($this->ref);
@@ -512 +473 @@
- $this->description = trim($this->description);
+ $this->description = trim($this->description);
@@ -515 +476 @@
- $this->status = (int) $this->status;
+ $this->status = (int) $this->status;
@@ -523,5 +483,0 @@
- // It possible we have empty val here if postparam WEBSITE_OTHERLANG is empty or set like this : 'en,,sv' or 'en,sv,'
- if (empty(trim($val))) {
- unset($tmparray[$key]);
- continue;
- }
@@ -554 +510 @@
- $sql .= ' WHERE rowid='.((int) $this->id);
+ $sql .= ' WHERE rowid='.$this->id;
@@ -574,3 +530 @@
- if (trim($val) == $this->lang) {
- continue;
- }
+ if (trim($val) == $this->lang) continue;
@@ -582 +536 @@
- //$result=$this->call_trigger('WEBSITE_MODIFY',$user);
+ //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
@@ -602,4 +556,4 @@
- * @param User $user User that deletes
- * @param bool $notrigger false=launch triggers, true=disable triggers
- *
- * @return int Return integer <0 if KO, >0 if OK
+ * @param User $user User that deletes
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ *
+ * @return int <0 if KO, >0 if OK
@@ -609,2 +562,0 @@
- global $conf;
-
@@ -618,2 +570,14 @@
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'website_page';
- $sql .= ' WHERE fk_website = '.((int) $this->id);
+ if (!$notrigger) {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //$result=$this->call_trigger('MYOBJECT_DELETE',$user);
+ //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ //// End call triggers
+ }
+ }
+
+ if (!$error) {
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' WHERE rowid='.$this->id;
@@ -629,8 +593,3 @@
- // Delete common code. This include execution of trigger.
- $result = $this->deleteCommon($user, $notrigger);
- if ($result <= 0) {
- $error++;
- }
-
- if (!$error && !empty($this->ref)) {
- $pathofwebsite = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$this->ref;
+ if (!$error && !empty($this->ref))
+ {
+ $pathofwebsite = DOL_DATA_ROOT.'/website/'.$this->ref;
@@ -654 +613 @@
- * Load a website its id and create a new one in database.
+ * Load an object from its id and create a new one in database.
@@ -665 +624 @@
- global $conf, $langs;
+ global $conf;
@@ -671,8 +630 @@
- dol_syslog(__METHOD__, LOG_DEBUG);
-
- $newref = dol_sanitizeFileName($newref);
-
- if (empty($newref)) {
- $this->error = 'ErrorBadParameter';
- return -1;
- }
+ dol_syslog(__METHOD__, LOG_DEBUG);
@@ -682,2 +634,3 @@
- // Check no site with ref exists
- if ($object->fetch(0, $newref) > 0) {
+ // Check no site with ref exists
+ if ($object->fetch(0, $newref) > 0)
+ {
@@ -696,2 +649,2 @@
- $pathofwebsiteold = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.dol_sanitizeFileName($oldref);
- $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.dol_sanitizeFileName($newref);
+ $pathofwebsiteold = $dolibarr_main_data_root.'/website/'.$oldref;
+ $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.$newref;
@@ -713,5 +665,0 @@
- $object->position = ((int) $object->position) + 1;
- $object->status = self::STATUS_DRAFT;
- if (empty($object->lang)) {
- $object->lang = substr($langs->defaultlang, 0, 2); // Should not happen. Protection for corrupted site with no languages
- }
@@ -724 +671,0 @@
- $this->error = $object->error;
@@ -729 +676,2 @@
- if (!$error) {
+ if (!$error)
+ {
@@ -735 +683,2 @@
- if (!is_link(dol_osencode($pathtomediasinwebsite))) {
+ if (!is_link(dol_osencode($pathtomediasinwebsite)))
+ {
@@ -755 +704,2 @@
- foreach ($listofpages as $pageid => $objectpageold) {
+ foreach ($listofpages as $pageid => $objectpageold)
+ {
@@ -764,2 +714,3 @@
- if (is_object($objectpagenew) && $objectpagenew->pageurl) {
- $filealias = $pathofwebsitenew.'/'.$objectpagenew->pageurl.'.php';
+ if (is_object($objectpagenew) && $objectpagenew->pageurl)
+ {
+ $filealias = $pathofwebsitenew.'/'.$objectpagenew->pageurl.'.php';
@@ -770,3 +721 @@
- if (!$result) {
- setEventMessages('Failed to write file '.$filealias, null, 'errors');
- }
+ if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
@@ -775,5 +724,4 @@
- if (!$result) {
- setEventMessages('Failed to write file '.$filetplnew, null, 'errors');
- }
-
- if ($pageid == $oldidforhome) {
+ if (!$result) setEventMessages('Failed to write file '.$filetplnew, null, 'errors');
+
+ if ($pageid == $oldidforhome)
+ {
@@ -782 +730,3 @@
- } else {
+ }
+ else
+ {
@@ -789 +739,2 @@
- if (!$error) {
+ if (!$error)
+ {
@@ -792,14 +743,16 @@
- $res = $object->update($user);
- if (!($res > 0)) {
- $error++;
- setEventMessages($object->error, $object->errors, 'errors');
- }
-
- if (!$error) {
- $filetpl = $pathofwebsitenew.'/page'.$newidforhome.'.tpl.php';
- $filewrapper = $pathofwebsitenew.'/wrapper.php';
-
- // Re-generates the index.php page to be the home page, and re-generates the wrapper.php
- //--------------------------------------------------------------------------------------
- $result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl, $filewrapper, $object);
- }
+ $res = $object->update($user);
+ if (!$res > 0)
+ {
+ $error++;
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+
+ if (!$error)
+ {
+ $filetpl = $pathofwebsitenew.'/page'.$newidforhome.'.tpl.php';
+ $filewrapper = $pathofwebsitenew.'/wrapper.php';
+
+ // Generate the index.php page to be the home page
+ //-------------------------------------------------
+ $result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl, $filewrapper);
+ }
@@ -828,3 +781,3 @@
- * @param integer $notooltip 1=Disable tooltip
- * @param int $maxlen Max length of visible user name
- * @param string $morecss Add more css on link
+ * @param integer $notooltip 1=Disable tooltip
+ * @param int $maxlen Max length of visible user name
+ * @param string $morecss Add more css on link
@@ -836,15 +789,15 @@
- global $dolibarr_main_authentication, $dolibarr_main_demo;
- global $menumanager;
-
-
- $result = '';
- $companylink = '';
-
- $label = ''.$langs->trans("WebSite").'';
- $label .= '
';
- $label .= ''.$langs->trans('Ref').': '.$this->ref.'
';
- $label .= ''.$langs->trans('MainLanguage').': '.$this->lang;
-
- $linkstart = ''.$langs->trans("WebSite").'';
+ $label .= '
';
+ $label .= ''.$langs->trans('Ref').': '.$this->ref.'
';
+ $label .= ''.$langs->trans('MainLanguage').': '.$this->lang;
+
+ $linkstart = 'picto ? $this->picto : 'generic'), ($notooltip ? '' : 'class="classfortooltip"')).$linkend);
- if ($withpicto != 2) {
- $result .= ' ';
- }
+ if ($withpicto)
+ {
+ $result .= ($linkstart.img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? '' : 'class="classfortooltip"')).$linkend);
+ if ($withpicto != 2) $result .= ' ';
@@ -866,3 +818,3 @@
- * Return the label of the status
- *
- * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
+ * 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
@@ -876,7 +828,7 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Return the label of a given status
- *
- * @param int $status Id status
- * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
- * @return string Label of status
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * 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
@@ -886 +838 @@
- // phpcs:enable
+ // phpcs:enable
@@ -889 +841,2 @@
- if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
+ if (empty($this->labelStatus) || empty($this->labelStatusShort))
+ {
@@ -892,4 +845,4 @@
- $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Offline');
- $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Online');
- $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Offline');
- $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Online');
+ $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled');
+ $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
+ $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Disabled');
+ $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
@@ -899,3 +852 @@
- if ($status == self::STATUS_VALIDATED) {
- $statusType = 'status4';
- }
+ if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
@@ -915 +866 @@
- global $user;
+ global $user;
@@ -918 +869 @@
- $this->specimen = 1;
+
@@ -924 +875 @@
- $this->status = 1;
+ $this->status = '';
@@ -945 +896,2 @@
- if (empty($website->id) || empty($website->ref)) {
+ if (empty($website->id) || empty($website->ref))
+ {
@@ -952 +904,2 @@
- if (!is_writable($conf->website->dir_temp)) {
+ if (!is_writable($conf->website->dir_temp))
+ {
@@ -960,2 +913 @@
- $count = 0;
- $countreallydeleted = 0;
+ $count = 0; $countreallydeleted = 0;
@@ -963 +915,2 @@
- if ($counttodelete != $countreallydeleted) {
+ if ($counttodelete != $countreallydeleted)
+ {
@@ -975 +928 @@
- $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo_small] = "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__";
+ $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo_small] = "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__";
@@ -978 +931 @@
- $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo_mini] = "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__";
+ $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo_mini] = "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__";
@@ -981 +934 @@
- $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo] = "file=logos%2Fthumbs%2F__LOGO_KEY__";
+ $arrayreplacementincss['file=logos%2Fthumbs%2F'.$mysoc->logo] = "file=logos%2Fthumbs%2F__LOGO_KEY__";
@@ -994,10 +947,2 @@
- dol_syslog("Copy pages from ".$srcdir." into ".$destdir);
- dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacementinfilename, 2, array('old', 'back'));
-
- // Copy file README.md and LICENSE from directory containers into directory root
- if (dol_is_file($conf->website->dir_temp.'/'.$website->ref.'/containers/README.md')) {
- dol_copy($conf->website->dir_temp.'/'.$website->ref.'/containers/README.md', $conf->website->dir_temp.'/'.$website->ref.'/README.md');
- }
- if (dol_is_file($conf->website->dir_temp.'/'.$website->ref.'/containers/LICENSE')) {
- dol_copy($conf->website->dir_temp.'/'.$website->ref.'/containers/LICENSE', $conf->website->dir_temp.'/'.$website->ref.'/LICENSE');
- }
+ dol_syslog("Copy content from ".$srcdir." into ".$destdir);
+ dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacementinfilename, 2);
@@ -1021,3 +966 @@
- if (dol_is_file($cssindestdir)) {
- dolReplaceInFile($cssindestdir, $arrayreplacementincss);
- }
+ dolReplaceInFile($cssindestdir, $arrayreplacementincss);
@@ -1026,3 +969 @@
- if (dol_is_file($htmldeaderindestdir)) {
- dolReplaceInFile($htmldeaderindestdir, $arrayreplacementincss);
- }
+ dolReplaceInFile($htmldeaderindestdir, $arrayreplacementincss);
@@ -1033 +974,2 @@
- if (empty($fp)) {
+ if (empty($fp))
+ {
@@ -1043 +985,2 @@
- foreach ($listofpages as $pageid => $objectpageold) {
+ foreach ($listofpages as $pageid => $objectpageold)
+ {
@@ -1048 +991,2 @@
- foreach ($listofpages as $pageid => $objectpageold) {
+ foreach ($listofpages as $pageid => $objectpageold)
+ {
@@ -1051,2 +995,4 @@
- foreach ($listofpages as $pageid2 => $objectpageold2) {
- if ($pageid2 == $objectpageold->fk_page) {
+ foreach ($listofpages as $pageid2 => $objectpageold2)
+ {
+ if ($pageid2 == $objectpageold->fk_page)
+ {
@@ -1060 +1006,2 @@
- foreach ($listofpages as $pageid => $objectpageold) {
+ foreach ($listofpages as $pageid => $objectpageold)
+ {
@@ -1064,4 +1011 @@
- $line = '-- File generated by Dolibarr '.DOL_VERSION.' -- '.dol_print_date(dol_now('gmt'), 'standard', 'gmt').' UTC --;';
- $line .= "\n";
-
- $line .= '-- Page ID '.$objectpageold->id.' -> '.$objectpageold->newid.'__+MAX_llx_website_page__ - Aliases '.$allaliases.' --;'; // newid start at 1, 2...
+ $line = '-- Page ID '.$objectpageold->id.' -> '.$objectpageold->newid.'__+MAX_llx_website_page__ - Aliases '.$allaliases.' --;'; // newid start at 1, 2...
@@ -1072 +1016 @@
- $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames)';
+ $line = 'INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias)';
@@ -1092 +1035,0 @@
- // Make substitution with a generic path into htmlheader content
@@ -1099 +1041,0 @@
-
@@ -1105 +1046,0 @@
- // Make substitution with a generic path into page content
@@ -1112,5 +1052,0 @@
- $stringtoexport = str_replace('"image/'.$website->ref.'/', '"image/__WEBSITE_KEY__/', $stringtoexport); // When we have a link src="image/websiteref/file.png" into html content
- $stringtoexport = str_replace('"/image/'.$website->ref.'/', '"/image/__WEBSITE_KEY__/', $stringtoexport); // When we have a link src="/image/websiteref/file.png" into html content
- $stringtoexport = str_replace('"js/'.$website->ref.'/', '"js/__WEBSITE_KEY__/', $stringtoexport);
- $stringtoexport = str_replace('"/js/'.$website->ref.'/', '"/js/__WEBSITE_KEY__/', $stringtoexport);
-
@@ -1120,0 +1057,2 @@
+ // When we have a link src="image/websiteref/file.png" into html content
+ $stringtoexport = str_replace('="image/'.$website->ref.'/', '="image/__WEBSITE_KEY__/', $stringtoexport);
@@ -1123,2 +1061 @@
- $line .= "'".$this->db->escape($objectpageold->author_alias)."', ";
- $line .= (int) $objectpageold->allowed_in_frames;
+ $line .= "'".$this->db->escape($objectpageold->author_alias)."'";
@@ -1127 +1063,0 @@
-
@@ -1132,3 +1068,4 @@
- if ($this->fk_default_home > 0 && ($objectpageold->id == $this->fk_default_home) && ($objectpageold->newid > 0)) { // This is the record with home page
- // Warning: We must keep llx_ here. It is a generic SQL.
- $line = "UPDATE llx_website SET fk_default_home = ".($objectpageold->newid > 0 ? $this->db->escape($objectpageold->newid)."__+MAX_llx_website_page__" : "null")." WHERE rowid = __WEBSITE_ID__;";
+ if ($this->fk_default_home > 0 && ($objectpageold->id == $this->fk_default_home) && ($objectpageold->newid > 0)) // This is the record with home page
+ {
+ // Warning: We must keep llx_ here. It is a generic SQL.
+ $line = "UPDATE llx_website SET fk_default_home = ".($objectpageold->newid > 0 ? $this->db->escape($objectpageold->newid)."__+MAX_llx_website_page__" : "null")." WHERE rowid = __WEBSITE_ID__;";
@@ -1140,6 +1076,0 @@
- $line = "\n-- For Dolibarr v14+ --;\n";
- $line .= "UPDATE llx_website SET lang = '".$this->db->escape($this->lang)."' WHERE rowid = __WEBSITE_ID__;\n";
- $line .= "UPDATE llx_website SET otherlang = '".$this->db->escape($this->otherlang)."' WHERE rowid = __WEBSITE_ID__;\n";
- $line .= "\n";
- fputs($fp, $line);
-
@@ -1147 +1078,2 @@
- dolChmod($filesql);
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($filesql, octdec($conf->global->MAIN_UMASK));
@@ -1157 +1089,2 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
@@ -1159 +1092,3 @@
- } else {
+ }
+ else
+ {
@@ -1170,2 +1105,2 @@
- * @param string $pathtofile Full path of zip file
- * @return int Return integer <0 if KO, Id of new website if OK
+ * @param string $pathtofile Path of zip file
+ * @return int <0 if KO, Id of new website if OK
@@ -1179,2 +1113,0 @@
- $pathtofile = dol_sanitizePathName($pathtofile);
-
@@ -1182 +1115,2 @@
- if (empty($object->ref)) {
+ if (empty($object->ref))
+ {
@@ -1184,4 +1118,4 @@
- return -2;
- }
-
- dol_delete_dir_recursive($conf->website->dir_temp."/".$object->ref);
+ return -1;
+ }
+
+ dol_delete_dir_recursive($conf->website->dir_temp.'/'.$object->ref);
@@ -1191 +1125,2 @@
- if (!preg_match('/^website_(.*)-(.*)$/', $filename, $reg)) {
+ if (!preg_match('/^website_(.*)-(.*)$/', $filename, $reg))
+ {
@@ -1193 +1128 @@
- return -3;
+ return -1;
@@ -1198 +1133,2 @@
- if (!empty($result['error'])) {
+ if (!empty($result['error']))
+ {
@@ -1200 +1136 @@
- return -4;
+ return -1;
@@ -1224 +1160,2 @@
- if (!$result) {
+ if (!$result)
+ {
@@ -1232 +1169 @@
- $sqlfile = $conf->website->dir_temp."/".$object->ref.'/website_pages.sql';
+ $sqlfile = $conf->website->dir_temp.'/'.$object->ref.'/website_pages.sql';
@@ -1241 +1178,2 @@
- if ($resql) {
+ if ($resql)
+ {
@@ -1247,3 +1185,4 @@
- $runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1, 0, 0, 1); // The maxrowid of table is searched into this function two
- if ($runsql <= 0) {
- $this->errors[] = 'Failed to load sql file '.$sqlfile.' (ret='.((int) $runsql).')';
+ $runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1); // The maxrowid of table is searched into this function two
+ if ($runsql <= 0)
+ {
+ $this->errors[] = 'Failed to load sql file '.$sqlfile;
@@ -1257,2 +1196,4 @@
- if ($fp) {
- while (!feof($fp)) {
+ if ($fp)
+ {
+ while (!feof($fp))
+ {
@@ -1263 +1204,2 @@
- if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg)) {
+ if (preg_match('/^-- Page ID (\d+)\s[^\s]+\s(\d+).*Aliases\s(.*)\s--;/i', $buf, $reg))
+ {
@@ -1283,3 +1225,6 @@
- if (is_array($aliasesarray)) {
- foreach ($aliasesarray as $aliasshortcuttocreate) {
- if (trim($aliasshortcuttocreate)) {
+ if (is_array($aliasesarray))
+ {
+ foreach ($aliasesarray as $aliasshortcuttocreate)
+ {
+ if (trim($aliasshortcuttocreate))
+ {
@@ -1301 +1246 @@
- $sql = "SELECT fk_default_home FROM ".MAIN_DB_PREFIX."website WHERE rowid = ".((int) $object->id);
+ $sql = 'SELECT fk_default_home FROM '.MAIN_DB_PREFIX.'website WHERE rowid = '.$object->id;
@@ -1315,3 +1260,4 @@
- dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php', $object);
-
- if ($error) {
+ dolSaveIndexPage($pathofwebsite, $pathofwebsite.'/index.php', $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php', $pathofwebsite.'/wrapper.php');
+
+ if ($error)
+ {
@@ -1320 +1266,3 @@
- } else {
+ }
+ else
+ {
@@ -1327 +1275 @@
- * Rebuild all files of all the pages/containers of a website. Rebuild also the index and wrapper.php file.
+ * Rebuild all files of a containers of a website. TODO Add other files too.
@@ -1330 +1278 @@
- * @return int Return integer <0 if KO, >=0 if OK
+ * @return int <0 if KO, >=0 if OK
@@ -1339,2 +1287,3 @@
- if (empty($object->ref)) {
- $this->error = 'Function rebuildWebSiteFiles called on object not loaded (object->ref is empty)';
+ if (empty($object->ref))
+ {
+ $this->error = 'Function importWebSite called on object not loaded (object->ref is empty)';
@@ -1346 +1295 @@
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."website_page WHERE fk_website = ".((int) $this->id);
+ $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page WHERE fk_website = '.$this->id;
@@ -1349 +1298 @@
- if (!$resql) {
+ if (! $resql) {
@@ -1356,2 +1305 @@
- // Loop on each container/page
- $i = 0;
+ $i=0;
@@ -1374,9 +1322,7 @@
- // Add main alias to list of alternative aliases
- if (!empty($objectpagestatic->pageurl) && !in_array($objectpagestatic->pageurl, $aliasesarray)) {
- $aliasesarray[] = $objectpagestatic->pageurl;
- }
-
- // Regenerate also all aliases pages (pages with a natural name) by calling dolSavePageAlias()
- if (is_array($aliasesarray)) {
- foreach ($aliasesarray as $aliasshortcuttocreate) {
- if (trim($aliasshortcuttocreate)) {
+ // Regenerate alternative aliases pages
+ if (is_array($aliasesarray))
+ {
+ foreach ($aliasesarray as $aliasshortcuttocreate)
+ {
+ if (trim($aliasshortcuttocreate))
+ {
@@ -1384 +1330 @@
- $result = dolSavePageAlias($filealias, $object, $objectpagestatic); // This includes also a copy into sublanguage directories.
+ $result = dolSavePageAlias($filealias, $object, $objectpagestatic);
@@ -1396,13 +1342,2 @@
- if (!$error) {
- // Save index.php and wrapper.php
- $pathofwebsite = $conf->website->dir_output.'/'.$object->ref;
- $fileindex = $pathofwebsite.'/index.php';
- $filetpl = '';
- if ($object->fk_default_home > 0) {
- $filetpl = $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php';
- }
- $filewrapper = $pathofwebsite.'/wrapper.php';
- dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object); // This includes also a version of index.php into sublanguage directories
- }
-
- if ($error) {
+ if ($error)
+ {
@@ -1410 +1345,3 @@
- } else {
+ }
+ else
+ {
@@ -1438,3 +1375 @@
- if (!is_object($weblangs)) {
- return 'ERROR componentSelectLang called with parameter $weblangs not defined';
- }
+ if (!is_object($weblangs)) return 'ERROR componentSelectLang called with parameter $weblangs not defined';
@@ -1450 +1385 @@
- 'zh'=>'zh_CN',
+ 'zh'=>'zh_TW',
@@ -1473,8 +1408,7 @@
- if (!empty($websitepagefile)) {
- $websitepagefileshort = basename($websitepagefile);
- if ($websitepagefileshort == 'index.php') {
- $pageid = $website->fk_default_home;
- } else {
- $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), $websitepagefileshort);
- }
- if ($pageid > 0) {
+ if (!empty($websitepagefile))
+ {
+ $websitepagefileshort = basename($websitepagefile);
+ if ($websitepagefileshort == 'index.php') $pageid = $website->fk_default_home;
+ else $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), $websitepagefileshort);
+ if ($pageid > 0)
+ {
@@ -1486 +1420,2 @@
- if (!is_array($languagecodes) && $pageid > 0) {
+ if (!is_array($languagecodes) && $pageid > 0)
+ {
@@ -1491,5 +1426,3 @@
- $sql .= " WHERE wp.fk_website = ".((int) $website->id);
- $sql .= " AND (wp.fk_page = ".((int) $pageid)." OR wp.rowid = ".((int) $pageid);
- if ($tmppage->fk_page > 0) {
- $sql .= " OR wp.fk_page = ".((int) $tmppage->fk_page)." OR wp.rowid = ".((int) $tmppage->fk_page);
- }
+ $sql .= " WHERE wp.fk_website = ".$website->id;
+ $sql .= " AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid;
+ if ($tmppage->fk_page > 0) $sql .= " OR wp.fk_page = ".$tmppage->fk_page." OR wp.rowid = ".$tmppage->fk_page;
@@ -1499,2 +1432,4 @@
- if ($resql) {
- while ($obj = $this->db->fetch_object($resql)) {
+ if ($resql)
+ {
+ while ($obj = $this->db->fetch_object($resql))
+ {
@@ -1502,6 +1437,2 @@
- if ($obj->rowid == $pageid) {
- $newlang = $obj->lang;
- }
- if (!in_array($newlang, $languagecodes)) {
- $languagecodes[] = $newlang;
- }
+ if ($obj->rowid == $pageid) $newlang = $obj->lang;
+ if (!in_array($newlang, $languagecodes)) $languagecodes[] = $newlang;
@@ -1514 +1445,2 @@
- if (!empty($websitepagefile)) {
+ if (!empty($websitepagefile))
+ {
@@ -1516 +1448,2 @@
- if ($pageid > 0) {
+ if ($pageid > 0)
+ {
@@ -1519,3 +1452 @@
- if (!in_array($pagelang, $languagecodes)) {
- $languagecodes[] = $pagelang; // We add language code of page into combo list
- }
+ if (!in_array($pagelang, $languagecodes)) $languagecodes[] = $pagelang; // We add language code of page into combo list
@@ -1532,3 +1463 @@
- if (!preg_match('/^\//', $url)) {
- $url = '/'.$url;
- }
+ if (! preg_match('/^\//', $url)) $url = '/'.$url;
@@ -1564 +1493,2 @@
- if ($languagecodeselected) {
+ if ($languagecodeselected)
+ {
@@ -1572,4 +1502,2 @@
- if ($countrycode == 'us') {
- $label = preg_replace('/\s*\(.*\)/', '', $label);
- }
- $out .= ''.$label.'';
+ if ($countrycode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label);
+ $out .= '
'.$label.'';
@@ -1577 +1505 @@
- $out .= '