/[drupal]/contributions/modules/boost/boost.admin.inc
ViewVC logotype

Diff of /contributions/modules/boost/boost.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1.2.3.2.112, Fri Nov 13 20:02:45 2009 UTC revision 1.1.2.1.2.3.2.113, Fri Nov 13 23:03:35 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: boost.admin.inc,v 1.1.2.1.2.3.2.111 2009/11/11 08:14:03 mikeytown2 Exp $  // $Id: boost.admin.inc,v 1.1.2.1.2.3.2.112 2009/11/13 20:02:45 mikeytown2 Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 1165  function boost_count_core_db($all = FALS Line 1165  function boost_count_core_db($all = FALS
1165  /**  /**
1166   * Flushes boost page cache   * Flushes boost page cache
1167   */   */
1168  function boost_clear_cache_submit($form, &$form_state) {  function boost_clear_cache_submit($form, &$form_state, $first = TRUE) {
1169    // Temp fix for bug in form api & buttons    // Temp fix for bug in form api & buttons
1170    // Check to make sure this button was actually called    // Check to make sure this button was actually called
1171    $value = array_find_element_by_key('op', $form);    if (!boost_admin_button_router(0, $first, $form, $form_state)) {
   if (strpos($value, '0') != 1) {  
     drupal_set_message(t('FormAPI Bug Encountered; try again'), 'error');  
1172      return FALSE;      return FALSE;
1173    }    }
1174    
# Line 1197  function boost_clear_cache_parallel($dir Line 1195  function boost_clear_cache_parallel($dir
1195  /**  /**
1196   * Flushes all expired pages from database   * Flushes all expired pages from database
1197   */   */
1198  function boost_clear_expired_cache_submit($form, &$form_state) {  function boost_clear_expired_cache_submit($form, &$form_state, $first = TRUE) {
1199    // Temp fix for bug in form api & buttons    // Temp fix for bug in form api & buttons
1200    // Check to make sure this button was actually called    // Check to make sure this button was actually called
1201    $value = array_find_element_by_key('op', $form);    if (!boost_admin_button_router(1, $first, $form, $form_state)) {
   if (strpos($value, '1') != 1) {  
     drupal_set_message(t('FormAPI Bug Encountered; try again'), 'error');  
1202      return FALSE;      return FALSE;
1203    }    }
1204    
# Line 1220  function boost_clear_expired_cache_submi Line 1216  function boost_clear_expired_cache_submi
1216  /**  /**
1217   * Resets boost database & cache directory   * Resets boost database & cache directory
1218   */   */
1219  function boost_reset_database_file_submit($form, &$form_state) {  function boost_reset_database_file_submit($form, &$form_state, $first = TRUE) {
1220    // Temp fix for bug in form api & buttons    // Temp fix for bug in form api & buttons
1221    // Check to make sure this button was actually called    // Check to make sure this button was actually called
1222    $value = array_find_element_by_key('op', $form);    if (!boost_admin_button_router(4, $first, $form, $form_state)) {
   if (strpos($value, '4') != 1) {  
     drupal_set_message(t('FormAPI Bug Encountered; try again'), 'error');  
1223      return FALSE;      return FALSE;
1224    }    }
1225    
# Line 1248  function boost_reset_database_file_submi Line 1242  function boost_reset_database_file_submi
1242  /**  /**
1243   * Stop Crawler   * Stop Crawler
1244   */   */
1245  function boost_stop_crawler_submit($form, &$form_state) {  function boost_stop_crawler_submit($form, &$form_state, $first = TRUE) {
1246    // Temp fix for bug in form api & buttons    // Temp fix for bug in form api & buttons
1247    // Check to make sure this button was actually called    // Check to make sure this button was actually called
1248    $value = array_find_element_by_key('op', $form);    if (!boost_admin_button_router(2, $first, $form, $form_state)) {
   if (strpos($value, '2') != 1) {  
     drupal_set_message(t('FormAPI Bug Encountered; try again'), 'error');  
1249      return FALSE;      return FALSE;
1250    }    }
1251    
# Line 1265  function boost_stop_crawler_submit($form Line 1257  function boost_stop_crawler_submit($form
1257  /**  /**
1258   * Reset Crawler   * Reset Crawler
1259   */   */
1260  function boost_reset_crawler_submit($form, &$form_state) {  function boost_reset_crawler_submit($form, &$form_state, $first = TRUE) {
1261    // Temp fix for bug in form api & buttons    // Temp fix for bug in form api & buttons
1262    // Check to make sure this button was actually called    // Check to make sure this button was actually called
1263    $value = array_find_element_by_key('op', $form);    if (!boost_admin_button_router(3, $first, $form, $form_state)) {
   if (strpos($value, '3') != 1) {  
     drupal_set_message(t('FormAPI Bug Encountered; try again'), 'error');  
1264      return FALSE;      return FALSE;
1265    }    }
1266    
# Line 1314  function boost_array_find($needle, $hays Line 1304  function boost_array_find($needle, $hays
1304   *   *
1305   * http://php.net/array-key-exists#85184   * http://php.net/array-key-exists#85184
1306   */   */
1307  function &array_find_element_by_key($key, &$form) {  function &boost_array_find_element_by_key($key, &$form) {
1308    if (array_key_exists($key, $form)) {    if (array_key_exists($key, $form)) {
1309      $ret =& $form[$key];      $ret =& $form[$key];
1310      return $ret;      return $ret;
1311    }    }
1312    foreach ($form as $k => $v) {    foreach ($form as $k => $v) {
1313      if (is_array($v)) {      if (is_array($v)) {
1314        $ret =& array_find_element_by_key($key, $form[$k]);        $ret =& boost_array_find_element_by_key($key, $form[$k]);
1315        if ($ret) {        if ($ret) {
1316          return $ret;          return $ret;
1317        }        }
# Line 1330  function &array_find_element_by_key($key Line 1320  function &array_find_element_by_key($key
1320    return FALSE;    return FALSE;
1321  }  }
1322    
1323    function boost_admin_button_router($number, $first, $form, &$form_state) {
1324      $value = boost_array_find_element_by_key('op', $form);
1325      if (strpos($value, (string)$number) != 1) {
1326        $correct = substr($value, 1, 1);
1327        if ($first) {
1328          drupal_set_message(t('FormAPI Bug Encountered; trying to work around the bug. Given: %given Wanted: %wanted.', array('%given' => $number, '%wanted' => $correct)), 'warning');
1329          switch ($correct) {
1330            case 0:
1331              boost_clear_cache_submit($form, $form_state, FALSE);
1332              break;
1333            case 1:
1334              boost_clear_expired_cache_submit($form, $form_state, FALSE);
1335              break;
1336            case 2:
1337              boost_stop_crawler_submit($form, $form_state, FALSE);
1338              break;
1339            case 3:
1340              boost_reset_crawler_submit($form, $form_state, FALSE);
1341              break;
1342            case 4:
1343              boost_reset_database_file_submit($form, $form_state, FALSE);
1344              break;
1345          }
1346        }
1347        else {
1348          drupal_set_message(t('FormAPI Bug Encountered; try again. Given: %given Wanted: %wanted.', array('%given' => $number, '%wanted' => $correct)), 'error');
1349        }
1350        return FALSE;
1351      }
1352      return TRUE;
1353    }

Legend:
Removed from v.1.1.2.1.2.3.2.112  
changed lines
  Added in v.1.1.2.1.2.3.2.113

  ViewVC Help
Powered by ViewVC 1.1.2