public function create($data) { if ($this->page_path === false) { $this->page_path = $this->BuilderEngine->get_page_path(); } $children = $data['children']; unset($data['children']); $data['active'] = 'yes'; $page_path = $data['global'] == 'yes' ? "layout" : $this->page_path; $data['version'] = $this->versions->get_pending_or_active_page_version_id($page_path); if ($this->block_version_exists($data['name'], $data['version'])) { return; } $this->db->insert('blocks', $data); PC::creating_block($data); foreach ($children as $key => $childname) { $insert = array("parent" => $data['name'], "child" => $childname, "version" => $data['version'], "sort_order" => $key); $this->db->insert('block_relations', $insert); } }