--- featured_content.admin.inc 2010-08-11 08:12:51.000000000 +0200 +++ featured_content_cache.admin.inc 2010-09-26 17:36:57.000000000 +0200 @@ -43,6 +43,12 @@ function featured_content_add_block_form db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $delta); } + // if 'generate sort cache' is true, we must generate cache table, so a progress bar should appear via ahah + if($form_state['values'][$delta]['filter']['sort_cache_generate']=='true'){ + featured_content_generate_sort_cache($delta); // this function is located on featured_content.module + drupal_set_message(t('The Featured Cache Table Has been generated for this block.')); + } + drupal_set_message(t('The Featured Content Block has been created.')); cache_clear_all(); $form_state['redirect'] = 'admin/build/block'; @@ -80,6 +86,8 @@ function featured_content_delete_block_s // clear data in block tables db_query("DELETE FROM {blocks} WHERE module = 'featured_content' AND delta = %d", $delta); db_query("DELETE FROM {blocks_roles} WHERE module = 'featured_content' AND delta = %d", $delta); + //Xavi Sanz: Here we delete cache records if they exists + db_query("DELETE FROM {featured_content_sort_cache} WHERE delta = %d",$delta); drupal_set_message(t('The "%name" block has been removed.', array('%name' => $form_state['values']['block_title']))); cache_clear_all(); @@ -188,6 +196,8 @@ function featured_content_configure($del 'random' => t('Randomly Chosen from All Available'), 'terms_desc' => t('Closest Match to Current Page by Terms'), 'terms_asc' => t('Furthest Match to Current Page by Terms'), + 'words_desc' => t('Closest Match to Current Page by Title&Teaser'), + 'words_asc' => t('Furthest Match to Current Page by Title&Teaser'), 'none' => t('None - Use Order Provided if Available'), ); $form['featured-block']['featured_content_block_sort'] = array( @@ -400,6 +410,30 @@ function featured_content_configure($del '#collapsible' => TRUE, '#collapsed' => FALSE, ); + //Xavi Sanz::Begin Adding 'use sort cache' option + $sort_cache_options = array( + 'true' => t('TRUE'), + 'false' => t('FALSE'), + ); + $form['featured-block']['filter']['featured_content_block_sort_cache'] = array( + '#type' => 'select', + '#title' => t('Use Sort Cache'), + '#options' => $sort_cache_options, + '#default_value' => featured_content_get_value($featured_content['filter']['sort_cache'], 'false'), + '#description' => t('Setting this option to TRUE, featured_content will use cache. The cache offers better performance when there is a large number of nodes. This option ONLY works when filtered content type is applied'), + ); + $sort_cache_generate_options = array( + 'true' => t('TRUE'), + 'false' => t('FALSE'), + ); + $form['featured-block']['filter']['featured_content_block_sort_cache_generate'] = array( + '#type' => 'select', + '#title' => t('Generate Sort Cache on updating block'), + '#options' => $sort_cache_generate_options, + '#default_value' => featured_content_get_value($featured_content['filter']['sort_cache_generate'], 'false'), + '#description' => t('Setting this option to TRUE, featured_content will generate the cache (if "Use Sort Cache" is set to "TRUE") on updating/saving this block. This task may take few minutes or hours, depending on system and number of nodes.'), + ); + //Xavi Sanz::End $form['featured-block']['filter']['filter_include_node'] = array( '#type' => 'checkbox', '#title' => t('Include Node Being Viewed'), @@ -773,6 +807,10 @@ function featured_content_save($delta, $ } // filter settings + // Xavi Sanz::BEGIN save sort cache option + $featured_blocks[$delta]['filter']['sort_cache'] = $edit['featured_content_block_sort_cache']; + $featured_blocks[$delta]['filter']['sort_cache_generate'] = $edit['featured_content_block_sort_cache_generate']; + // Xavi Sanz::END $featured_blocks[$delta]['filter']['include_node'] = $edit['filter_include_node']; $featured_blocks[$delta]['filter']['paths']['match'][0] = $edit['filter_paths_match_0']; $featured_blocks[$delta]['filter']['paths']['match'][1] = $edit['filter_paths_match_1']; @@ -819,6 +857,14 @@ function featured_content_save($delta, $ } variable_set('featured_content_blocks', $featured_blocks); + + // if 'generate sort cache' is true, we must generate cache table, so a progress bar should appear via ahah + if($featured_blocks[$delta]['filter']['sort_cache_generate']=='true'){ + featured_content_generate_sort_cache($delta); // this function is located on featured_content.module + drupal_set_message(t('The Featured Cache Table Has been generated for this block.')); + } + + } /**