Commit bcf2179c authored by merlinofchaos's avatar merlinofchaos
Browse files

Change schema so searching is always by language

parent 45489776
......@@ -43,8 +43,16 @@ function advanced_help_schema() {
'not null' => TRUE,
'description' => t('The topic id.'),
),
'language' => array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => t('The language this search index relates to.'),
),
),
'primary key' => array('sid'),
'indexes' => array('language' => array('language')),
);
return $schema;
......
......@@ -210,7 +210,7 @@ function advanced_help_index_page($module = '') {
$breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb));
drupal_set_breadcrumb($breadcrumb);
$output .= theme('advanced_help_topic', 'advanced_help', 'using-advanced-help');
$output .= t('This is a demo link to the popup: ') . theme('advanced_help_topic', 'advanced_help', 'using-advanced-help');
return $output;
}
......@@ -554,7 +554,8 @@ function advanced_help_search($op = 'search', $keys = null) {
* the search system.
*/
function advanced_help_get_sids(&$topics) {
$result = db_query("SELECT * FROM {advanced_help_index}");
global $language;
$result = db_query("SELECT * FROM {advanced_help_index} WHERE language = '%s'", $language->language);
while ($sid = db_fetch_object($result)) {
if (empty($topics[$sid->module][$sid->topic])) {
db_query("DELETE FROM {advanced_help_index} WHERE sid = %d", $sid->sid);
......@@ -569,6 +570,8 @@ function advanced_help_get_sids(&$topics) {
* Implementation of hook_update_index().
*/
function advanced_help_update_index() {
global $language;
// If we got interrupted by limit, this will contain the last module
// and topic we looked at.
$last = variable_get('advanced_help_last_cron', array('time' => 0));
......@@ -600,11 +603,11 @@ function advanced_help_update_index() {
$file = advanced_help_get_topic_filename($module, $topic);
if ($file && (empty($info['sid']) || filemtime($file) > $last['time'])) {
if (empty($info['sid'])) {
db_query("INSERT INTO {advanced_help_index} (module, topic) VALUES ('%s', '%s')", $module, $topic);
db_query("INSERT INTO {advanced_help_index} (module, topic, language) VALUES ('%s', '%s', '%s')", $module, $topic, $language->language);
$info['sid'] = db_last_insert_id('advanced_help_index', 'sid');
}
search_index($info['sid'], 'help', file_get_contents($file));
search_index($info['sid'], 'help', '<h1>' . $info['title'] . '</h1>' . file_get_contents($file));
$count++;
if ($count >= $limit) {
$last['topic'] = $topic;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment