Example #1
0
int WikiManage::wiki_full_search(const char *key, char **buf, int *size, int page)
{
	struct one_lang *which;

	SET_CURR_TITLE(key);

	if (wiki_check_full_search(key) == 0) 
		wiki_full_search_update(key);

	if (m_search_buf.page_total == 0)
		return wiki_not_found(buf, size, "Not found");

	if (page == 0) {
		m_curr_lang = &m_all_lang[0];
		wiki_push_back(STATUS_FULL_TEXT, key, 0, NULL);
	}

	return wiki_full_search_one_page(buf, size, page);
}
Example #2
0
int WikiManage::wiki_read_data(const sort_idx_t *p, char **buf, const char *title)
{
	char tmp[256];
	const char *key  = tmp;
	int n, pos, height;

	WikiData *wiki_data = CURR_WIKI(data);
	WikiIndex *wiki_index = CURR_WIKI(index);

	INIT_CURR_TITLE();

	if ((n = wiki_data->wd_sys_read((int)p->data_file_idx,
					p->data_pos, (int)p->data_len, m_curr_content, 2*1024*1024)) > 0) {

#if 0
		n = m_wiki_zh->wz_convert_2hans(m_curr_content, n, m_curr_page);
		memcpy(m_curr_content, m_curr_page, n);
		m_curr_content[n] = 0;
#endif

		m_curr_content[n] = 0;

		if (m_wiki_config->wc_get_need_translate()) {
			n = wiki_translate_format(m_curr_content, n, m_curr_page);
			memcpy(m_curr_content, m_curr_page, n);
			m_curr_content[n] = 0;
		}

		int split_total = wiki_split_content(n);

		if (title == NULL) {
			wiki_index->wi_get_key(p, tmp);
		} else {
			key = title;
		}
		SET_CURR_TITLE(key);

		wiki_find_key_pos(&pos, &height);

		int len;

		char bg[16], fg[16], link[16], bg_str[64];
		int font_size;

		m_wiki_config->wc_get_config(bg, fg, link, &font_size);

		sprintf(bg_str, "background:%s;\n", bg);

		/* TODO WIKI_START_HTML */
		len = sprintf(m_curr_page, WIKI_START_HTML,
				m_wiki_config->wc_get_body_image_flag() ? "" : bg_str ,
				fg, font_size, link, 
				m_wiki_socket->ws_get_bind_port(), pos, height, split_total - 1,
				m_wiki_config->wc_get_body_image_flag() ? " background=\"B.body.png\"" : "");

		memcpy(m_curr_page + len, m_curr_content + m_split_pos[0].start, m_split_pos[0].len);
		len += m_split_pos[0].len;

		len += sprintf(m_curr_page + len, WIKI_HTTP_END_HTML);

		*buf = m_curr_page;

		return len;
	}

	return 0;
}