Complete the fetchAll of modulebuilder + websitepage
This commit is contained in:
parent
200de22807
commit
61fddadc3f
@ -314,6 +314,77 @@ class MyObject extends CommonObject
|
|||||||
return count($this->lines)?1:0;
|
return count($this->lines)?1:0;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load list of objects in memory from the database.
|
||||||
|
*
|
||||||
|
* @param string $sortorder Sort Order
|
||||||
|
* @param string $sortfield Sort field
|
||||||
|
* @param int $limit limit
|
||||||
|
* @param int $offset Offset
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$records=array();
|
||||||
|
|
||||||
|
$sql = 'SELECT';
|
||||||
|
$sql .= ' t.rowid';
|
||||||
|
// TODO Gett all fields
|
||||||
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
|
||||||
|
$sql .= ' WHERE t.entity = '.$conf->entity;
|
||||||
|
// Manage filter
|
||||||
|
$sqlwhere = array();
|
||||||
|
if (count($filter) > 0) {
|
||||||
|
foreach ($filter as $key => $value) {
|
||||||
|
if ($key=='t.rowid') {
|
||||||
|
$sqlwhere[] = $key . '='. $value;
|
||||||
|
} else {
|
||||||
|
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($sqlwhere) > 0) {
|
||||||
|
$sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($sortfield)) {
|
||||||
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
if (!empty($limit)) {
|
||||||
|
$sql .= ' ' . $this->db->plimit($limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
while ($obj = $this->db->fetch_object($resql))
|
||||||
|
{
|
||||||
|
$record = new self($this->db);
|
||||||
|
|
||||||
|
$record->id = $obj->rowid;
|
||||||
|
// TODO Get other fields
|
||||||
|
|
||||||
|
//var_dump($record->id);
|
||||||
|
$records[$record->id] = $record;
|
||||||
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
return $records;
|
||||||
|
} else {
|
||||||
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update object into database
|
* Update object into database
|
||||||
*
|
*
|
||||||
|
|||||||
@ -169,6 +169,7 @@ class WebsitePage extends CommonObject
|
|||||||
$sql .= " t.aliasalt,";
|
$sql .= " t.aliasalt,";
|
||||||
$sql .= " t.title,";
|
$sql .= " t.title,";
|
||||||
$sql .= " t.description,";
|
$sql .= " t.description,";
|
||||||
|
$sql .= " t.image,";
|
||||||
$sql .= " t.keywords,";
|
$sql .= " t.keywords,";
|
||||||
$sql .= " t.htmlheader,";
|
$sql .= " t.htmlheader,";
|
||||||
$sql .= " t.content,";
|
$sql .= " t.content,";
|
||||||
@ -215,6 +216,7 @@ class WebsitePage extends CommonObject
|
|||||||
|
|
||||||
$this->title = $obj->title;
|
$this->title = $obj->title;
|
||||||
$this->description = $obj->description;
|
$this->description = $obj->description;
|
||||||
|
$this->image = $obj->image;
|
||||||
$this->keywords = $obj->keywords;
|
$this->keywords = $obj->keywords;
|
||||||
$this->htmlheader = $obj->htmlheader;
|
$this->htmlheader = $obj->htmlheader;
|
||||||
$this->content = $obj->content;
|
$this->content = $obj->content;
|
||||||
@ -243,7 +245,7 @@ class WebsitePage extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load object in memory from the database
|
* Load list of objects in memory from the database.
|
||||||
*
|
*
|
||||||
* @param string $websiteid Web site
|
* @param string $websiteid Web site
|
||||||
* @param string $sortorder Sort Order
|
* @param string $sortorder Sort Order
|
||||||
@ -254,7 +256,7 @@ class WebsitePage extends CommonObject
|
|||||||
* @param string $filtermode Filter mode (AND or OR)
|
* @param string $filtermode Filter mode (AND or OR)
|
||||||
* @return array|int int <0 if KO, array of pages if OK
|
* @return array|int int <0 if KO, array of pages if OK
|
||||||
*/
|
*/
|
||||||
public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
|
public function fetchAll($websiteid, $sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
|
||||||
{
|
{
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
@ -268,6 +270,7 @@ class WebsitePage extends CommonObject
|
|||||||
$sql .= " t.aliasalt,";
|
$sql .= " t.aliasalt,";
|
||||||
$sql .= " t.title,";
|
$sql .= " t.title,";
|
||||||
$sql .= " t.description,";
|
$sql .= " t.description,";
|
||||||
|
$sql .= " t.image,";
|
||||||
$sql .= " t.keywords,";
|
$sql .= " t.keywords,";
|
||||||
$sql .= " t.htmlheader,";
|
$sql .= " t.htmlheader,";
|
||||||
$sql .= " t.content,";
|
$sql .= " t.content,";
|
||||||
@ -300,7 +303,7 @@ class WebsitePage extends CommonObject
|
|||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($limit)) {
|
if (!empty($limit)) {
|
||||||
$sql .= ' ' . $this->db->plimit($limit, $offset);
|
$sql .= ' ' . $this->db->plimit($limit, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -318,6 +321,7 @@ class WebsitePage extends CommonObject
|
|||||||
$record->aliasalt = preg_replace('/,+$/', '', preg_replace('/^,+/', '', $obj->aliasalt));
|
$record->aliasalt = preg_replace('/,+$/', '', preg_replace('/^,+/', '', $obj->aliasalt));
|
||||||
$record->title = $obj->title;
|
$record->title = $obj->title;
|
||||||
$record->description = $obj->description;
|
$record->description = $obj->description;
|
||||||
|
$record->image = $obj->image;
|
||||||
$record->keywords = $obj->keywords;
|
$record->keywords = $obj->keywords;
|
||||||
$record->htmlheader = $obj->htmlheader;
|
$record->htmlheader = $obj->htmlheader;
|
||||||
$record->content = $obj->content;
|
$record->content = $obj->content;
|
||||||
@ -570,6 +574,7 @@ class WebsitePage extends CommonObject
|
|||||||
$this->aliasalt = 'specimenalt';
|
$this->aliasalt = 'specimenalt';
|
||||||
$this->title = 'My Page';
|
$this->title = 'My Page';
|
||||||
$this->description = 'This is my page';
|
$this->description = 'This is my page';
|
||||||
|
$this->image = '';
|
||||||
$this->keywords = 'keyword1, keyword2';
|
$this->keywords = 'keyword1, keyword2';
|
||||||
$this->htmlheader = '';
|
$this->htmlheader = '';
|
||||||
$this->content = '<html><body>This is a html content</body></html>';
|
$this->content = '<html><body>This is a html content</body></html>';
|
||||||
|
|||||||
@ -626,6 +626,7 @@ if ($action == 'addcontainer')
|
|||||||
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME','alpha');
|
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME','alpha');
|
||||||
$objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT','alpha');
|
$objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT','alpha');
|
||||||
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION','alpha');
|
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION','alpha');
|
||||||
|
$objectpage->image = GETPOST('WEBSITE_IMAGE','alpha');
|
||||||
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS','alpha');
|
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS','alpha');
|
||||||
$objectpage->lang = GETPOST('WEBSITE_LANG','aZ09');
|
$objectpage->lang = GETPOST('WEBSITE_LANG','aZ09');
|
||||||
$objectpage->htmlheader = GETPOST('htmlheader','none');
|
$objectpage->htmlheader = GETPOST('htmlheader','none');
|
||||||
@ -1127,6 +1128,7 @@ if ($action == 'updatemeta')
|
|||||||
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha');
|
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha');
|
||||||
$objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alpha');
|
$objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alpha');
|
||||||
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha');
|
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha');
|
||||||
|
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
|
||||||
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
|
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
|
||||||
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
|
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
|
||||||
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
|
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
|
||||||
@ -2451,6 +2453,7 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
|||||||
$pagealiasalt=$objectpage->aliasalt;
|
$pagealiasalt=$objectpage->aliasalt;
|
||||||
$pagetitle=$objectpage->title;
|
$pagetitle=$objectpage->title;
|
||||||
$pagedescription=$objectpage->description;
|
$pagedescription=$objectpage->description;
|
||||||
|
$pageimage=$objectpage->image;
|
||||||
$pagekeywords=$objectpage->keywords;
|
$pagekeywords=$objectpage->keywords;
|
||||||
$pagelang=$objectpage->lang;
|
$pagelang=$objectpage->lang;
|
||||||
$pagehtmlheader=$objectpage->htmlheader;
|
$pagehtmlheader=$objectpage->htmlheader;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user