/** * Add a content page in the database. * * @param number $parentId Parent page number. 0 = home page. * @return boolean */ public function addContent($parentId = 0) { $id = $this->domainDa->getNextSequenceValue('innomedia_pages_id_seq'); if ($this->domainDa->execute('INSERT INTO innomedia_pages (id, page, name) VALUES (' . $id . ',' . $this->domainDa->formatText($this->module . '/' . $this->page) . ',' . $this->domainDa->formatText($this->name) . ')')) { $this->id = $id; // Set the page name for the page tree path. $pageName = isset($this->parameters['slug']) ? $this->parameters['slug'] : ''; // Fallback to page title if the page slug is empty. if (!strlen($pageName)) { $pageName = isset($this->parameters['title']) ? $this->parameters['title'] : ''; } // Fallback to internal page name if the page title is empty. if (!strlen($pageName)) { $pageName = $this->name; } // Fallback to page id if the page name is still empty. if (!strlen($pageName)) { $pageName = $id; } // Add the page to the pages tree. $tree = new PageTree(); $tree->addPage($this->module, $this->page, $id, $parentId, $pageName); return true; } else { return false; } }