In this deliverable, I will throw some light on how the Context sensitive help will be integrated into Yioop seamlessly.
Yioop's Context sensitive help pages are just wiki pages in the Group Named "Help". The goal for making context sensitive help work on upgrade or New install is to make sure that a Group names "Help" exists. the Group ID for the "Help" group is constant and is assigned a value '3'.//Create a Group for Wiki HELP. $sql = "INSERT INTO GROUPS VALUES(" . HELP_GROUP_ID . ",'Help','" . $creation_time . "','" . ROOT_ID . "', '" . PUBLIC_BROWSE_REQUEST_JOIN . "', '" . GROUP_READ_WIKI . "', " . UP_DOWN_VOTING_GROUP . ", " . FOREVER . ")"; $db->execute($sql); $now = time(); $db->execute("INSERT INTO USER_GROUP VALUES (" . ROOT_ID . ", " . HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)"); $db->execute("INSERT INTO USER_GROUP VALUES (" . PUBLIC_USER_ID . ", " . HELP_GROUP_ID . ", " . ACTIVE_STATUS . ", $now)");
Now, once the Help group is created, the next step is to pull the wiki help articles from default.db and insert them into target database. Below code is used to perform the same :
function getWikiHelpPages() { $help_pages = array(); require_once(BASE_DIR . "/models/datasources/sqlite3_manager.php"); $default_dbm = new Sqlite3Manager(); $default_dbm->connect("", "", "", BASE_DIR . "/data/default_help.db"); if(!$default_dbm) { return false; } $group_model = new GroupModel(DB_NAME, true); $group_model->db = $default_dbm; $page_list = $group_model->getPageList(HELP_GROUP_ID, "en-US", '', 0, 200); foreach($page_list[1] as $page) { if(isset($page['TITLE'])) { $page_info = $group_model->getPageInfoByName( HELP_GROUP_ID, $page['TITLE'], "en-US", "api"); $page_content = str_replace("&", "&", $page_info['PAGE']); $page_content = html_entity_decode($page_content, ENT_QUOTES, "UTF-8"); $help_pages[$page['TITLE']] = $page_content; } } return $help_pages; }
//Insert Help pages $help_pages = getWikiHelpPages(); foreach($help_pages as $page_name => $page_content) { $page_content = str_replace("&", "&", $page_content); $page_content = @htmlentities($page_content, ENT_QUOTES, "UTF-8"); $group_model->setPageName(ROOT_ID, HELP_GROUP_ID, $page_name, $page_content, "en-US", "Creating Default Pages", "$page_name Help Page Created!", "Discuss the page in this thread!"); }
update GROUPS Set GROUP_ID = MAX_GROUP_ID where GROUP_ID= 3; update GROUP_ITEM Set GROUP_ID = MAX_GROUP_ID where GROUP_ID= 3; update GROUP_PAGE Set GROUP_ID = MAX_GROUP_ID where GROUP_ID= 3; update GROUP_PAGE_HISTORY Set GROUP_ID = MAX_GROUP_ID where GROUP_ID= 3; update USER_GROUP Set GROUP_ID = MAX_GROUP_ID where GROUP_ID= 3; update GROUPS Set GROUP_ID = MAX_GROUP_ID where GROUP_ID= 3;