From dc04ab316485b330cb418bc413f340581ff3155d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Dec 2017 13:24:21 +0100 Subject: [PATCH] Missing field in website module --- .../install/mysql/migration/6.0.0-7.0.0.sql | 1 + htdocs/install/mysql/tables/llx_website.sql | 1 + htdocs/langs/en_US/website.lang | 1 + htdocs/website/class/websitepage.class.php | 37 +++++++++++-------- htdocs/website/index.php | 23 ++++++++++-- 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index c6c29abfce0..25a5ac10716 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -64,6 +64,7 @@ ALTER TABLE llx_product_fournisseur_price ADD COLUMN default_vat_code varchar(10 ALTER TABLE llx_website_page ADD COLUMN fk_user_create integer; ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer; +ALTER TABLE llx_website_page ADD COLUMN type_container varchar(16) NOT NULL DEFAULT 'page'; -- For 7.0 diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index 6946b981c86..dd35116a91f 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -20,6 +20,7 @@ CREATE TABLE llx_website ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, + type_container varchar(16) NOT NULL DEFAULT 'page', entity integer NOT NULL DEFAULT 1, ref varchar(128) NOT NULL, description varchar(255), diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index dd01bcf6e0f..f5c2aeaf466 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -3,6 +3,7 @@ Shortname=Code WebsiteSetupDesc=Create here as much entry as number of different websites you need. Then go into menu Websites to edit them. DeleteWebsite=Delete website ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. +WEBSITE_TYPE_CONTAINER=Type of page/container WEBSITE_PAGENAME=Page name/alias WEBSITE_HTML_HEADER=HTML Header (common to all pages) HtmlHeaderPage=HTML specific header for page diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 15ffc7bed69..51c737673a0 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -53,6 +53,7 @@ class WebsitePage extends CommonObject public $fk_website; public $pageurl; + public $type_container; public $title; public $description; public $keywords; @@ -67,25 +68,26 @@ class WebsitePage extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'pageurl' =>array('type'=>'varchar(16)', 'label'=>'WEBSITE_PAGENAME', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Alias of page'), - 'title' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), - 'description' =>array('type'=>'varchar(255)', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), - 'keywords' =>array('type'=>'varchar(255)', 'label'=>'Keywords', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0), - 'lang' =>array('type'=>'varchar(6)', 'label'=>'Lang', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0), + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'pageurl' =>array('type'=>'varchar(16)', 'label'=>'WEBSITE_PAGENAME', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Alias of page'), + 'type_container' =>array('type'=>'varchar(16)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>0, 'position'=>11, 'comment'=>'Type of container'), + 'title' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), + 'description' =>array('type'=>'varchar(255)', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), + 'keywords' =>array('type'=>'varchar(255)', 'label'=>'Keywords', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0), + 'lang' =>array('type'=>'varchar(6)', 'label'=>'Lang', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0), //'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000), - 'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'), - 'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'), - 'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0), - 'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0), - 'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), + 'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'), + 'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'), + 'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0), + 'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0), + 'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>502), //'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>510), //'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>1, 'position'=>1000, 'notnull'=>-1), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>1, 'position'=>1000, 'notnull'=>-1), ); // END MODULEBUILDER PROPERTIES @@ -128,6 +130,7 @@ class WebsitePage extends CommonObject $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.fk_website,"; + $sql .= ' t.type_container,'; $sql .= " t.pageurl,"; $sql .= " t.title,"; $sql .= " t.description,"; @@ -165,6 +168,7 @@ class WebsitePage extends CommonObject $this->id = $obj->rowid; $this->fk_website = $obj->fk_website; + $this->type_container = $obj->type_container; $this->pageurl = $obj->pageurl; $this->title = $obj->title; $this->description = $obj->description; @@ -214,6 +218,7 @@ class WebsitePage extends CommonObject $sql = 'SELECT'; $sql .= ' t.rowid,'; $sql .= " t.fk_website,"; + $sql .= " t.type_container,"; $sql .= " t.pageurl,"; $sql .= " t.title,"; $sql .= " t.description,"; @@ -260,6 +265,7 @@ class WebsitePage extends CommonObject $record->id = $obj->rowid; $record->fk_website = $obj->fk_website; + $record->type_container = $obj->type_container; $record->pageurl = $obj->pageurl; $record->title = $obj->title; $record->description = $obj->description; @@ -497,7 +503,8 @@ class WebsitePage extends CommonObject $now=dol_now(); $this->fk_website = ''; - $this->pageurl = ''; + $this->type_container = 'page'; + $this->pageurl = 'specimen'; $this->title = 'My Page'; $this->description = 'This is my page'; $this->keywords = 'keyword1, keyword2'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 0250e2d28f8..79468ed85cf 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -54,6 +54,8 @@ $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $cancel=GETPOST('cancel','alpha'); +$type_container=GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); + $section_dir = GETPOST('section_dir', 'alpha'); $file_manager = GETPOST('file_manager', 'alpha'); @@ -144,7 +146,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' // Add directory -if ($action == 'add' && $permtouploadfile) +/* +if ($action == 'adddir' && $permtouploadfile) { $ecmdir->ref = 'NOTUSEDYET'; $ecmdir->label = GETPOST("label"); @@ -164,7 +167,7 @@ if ($action == 'add' && $permtouploadfile) clearstatcache(); } - +*/ // Remove directory if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') @@ -276,6 +279,7 @@ if ($action == 'add') preg_match('/(.*)<\/head>/is', $tmp['content'], $reg); $head = $reg[1]; + $objectpage->type_container = 'page'; $objectpage->pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/','-',$urltograbwithoutdomainandparam)); if (empty($objectpage->pageurl)) { @@ -454,6 +458,7 @@ if ($action == 'add') } else { + $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER','alpha'); $objectpage->title = GETPOST('WEBSITE_TITLE','alpha'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME','alpha'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION','alpha'); @@ -621,7 +626,7 @@ if ($action == 'delete') // Update css if ($action == 'updatecss') { - if (GETPOST('refreshsite') || GETPOST('refreshpage')) // If we tried to reload another site/page, we stay on editcss mode. + if (GETPOST('refreshsite','alpha') || GETPOST('refreshpage','alpha')) // If we tried to reload another site/page, we stay on editcss mode. { $action='editcss'; } @@ -859,6 +864,7 @@ if ($action == 'updatemeta') { $objectpage->old_object = clone $objectpage; + $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); @@ -1379,6 +1385,7 @@ if (count($object->records) > 0) $out.=''; @@ -1766,7 +1773,7 @@ if ($action == 'editmeta' || $action == 'create') print ' * '.$langs->trans("CreateByFetchingExternalPage").'

'; print ''; - print ''; */ + $type_container=$objectpage->type_container; $pageurl=$objectpage->pageurl; $pagetitle=$objectpage->title; $pagedescription=$objectpage->description; @@ -1817,6 +1825,13 @@ if ($action == 'editmeta' || $action == 'create') if (GETPOST('WEBSITE_LANG','aZ09')) $pagelang=GETPOST('WEBSITE_LANG','aZ09'); if (GETPOST('htmlheader','none')) $pagehtmlheader=GETPOST('htmlheader','none'); + print ''; + print '
'; + print '
'; print $langs->trans("URL"); print ''; print ' '; @@ -1803,6 +1810,7 @@ if ($action == 'editmeta' || $action == 'create') print '
'; + print $langs->trans('WEBSITE_TYPE_CONTAINER'); + print ''; + $arrayoftype=array('page'=>$langs->trans("Page"), 'banner'=>$langs->trans("Banner"), 'blogpost'=>$langs->trans("BlogPost")); + print $form->selectarray('WEBSITE_TYPE_CONTAINER', $arrayoftype, $type_container); + print '
'; print $langs->trans('WEBSITE_PAGENAME'); print '';