Skip to content

Commit

Permalink
Missing field in website module
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 2, 2017
1 parent 7b47ef3 commit dc04ab3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
1 change: 1 addition & 0 deletions htdocs/install/mysql/migration/6.0.0-7.0.0.sql
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions htdocs/install/mysql/tables/llx_website.sql
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/website.lang
Expand Up @@ -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
Expand Down
37 changes: 22 additions & 15 deletions htdocs/website/class/websitepage.class.php
Expand Up @@ -53,6 +53,7 @@ class WebsitePage extends CommonObject

public $fk_website;
public $pageurl;
public $type_container;
public $title;
public $description;
public $keywords;
Expand All @@ -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

Expand Down Expand Up @@ -128,6 +130,7 @@ public function fetch($id, $website_id = null, $page = null)
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.fk_website,";
$sql .= ' t.type_container,';
$sql .= " t.pageurl,";
$sql .= " t.title,";
$sql .= " t.description,";
Expand Down Expand Up @@ -165,6 +168,7 @@ public function fetch($id, $website_id = null, $page = null)
$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;
Expand Down Expand Up @@ -214,6 +218,7 @@ public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $of
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.fk_website,";
$sql .= " t.type_container,";
$sql .= " t.pageurl,";
$sql .= " t.title,";
$sql .= " t.description,";
Expand Down Expand Up @@ -260,6 +265,7 @@ public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $of

$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;
Expand Down Expand Up @@ -497,7 +503,8 @@ public function initAsSpecimen()
$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';
Expand Down
23 changes: 19 additions & 4 deletions htdocs/website/index.php
Expand Up @@ -54,6 +54,8 @@
$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');

Expand Down Expand Up @@ -144,7 +146,8 @@
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");
Expand All @@ -164,7 +167,7 @@
clearstatcache();
}

*/

// Remove directory
if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes')
Expand Down Expand Up @@ -276,6 +279,7 @@
preg_match('/<head>(.*)<\/head>/is', $tmp['content'], $reg);
$head = $reg[1];

$objectpage->type_container = 'page';
$objectpage->pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/','-',$urltograbwithoutdomainandparam));
if (empty($objectpage->pageurl))
{
Expand Down Expand Up @@ -454,6 +458,7 @@
}
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');
Expand Down Expand Up @@ -621,7 +626,7 @@
// 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';
}
Expand Down Expand Up @@ -859,6 +864,7 @@
{
$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');
Expand Down Expand Up @@ -1379,6 +1385,7 @@
$out.='<option value="'.$key.'"';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value
$out.='>';
$out.='['.$valpage->type_container.'] ';
$out.=$valpage->pageurl.' - '.$valpage->title;
if ($object->fk_default_home && $key == $object->fk_default_home) $out.=' ('.$langs->trans("HomePage").')';
$out.='</option>';
Expand Down Expand Up @@ -1766,7 +1773,7 @@

print ' * '.$langs->trans("CreateByFetchingExternalPage").'<br><hr>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefieldcreate">';
print '<tr><td class="titlefield">';
print $langs->trans("URL");
print '</td><td>';
print '<input class="flat minwidth300" type="text" name="externalurl" value="'.dol_escape_htmltag(GETPOST('externalurl','alpha')).'" placeholder="http://externalsite/pagetofetch"> ';
Expand Down Expand Up @@ -1803,6 +1810,7 @@
print '</td></tr>';
*/

$type_container=$objectpage->type_container;
$pageurl=$objectpage->pageurl;
$pagetitle=$objectpage->title;
$pagedescription=$objectpage->description;
Expand All @@ -1817,6 +1825,13 @@
if (GETPOST('WEBSITE_LANG','aZ09')) $pagelang=GETPOST('WEBSITE_LANG','aZ09');
if (GETPOST('htmlheader','none')) $pagehtmlheader=GETPOST('htmlheader','none');

print '<tr><td class="titlefield fieldrequired">';
print $langs->trans('WEBSITE_TYPE_CONTAINER');
print '</td><td>';
$arrayoftype=array('page'=>$langs->trans("Page"), 'banner'=>$langs->trans("Banner"), 'blogpost'=>$langs->trans("BlogPost"));
print $form->selectarray('WEBSITE_TYPE_CONTAINER', $arrayoftype, $type_container);
print '</td></tr>';

print '<tr><td class="titlefieldcreate fieldrequired">';
print $langs->trans('WEBSITE_PAGENAME');
print '</td><td>';
Expand Down

0 comments on commit dc04ab3

Please sign in to comment.