You are here

function block_patterns_get_arguments in Patterns 7

File

patterns_components/components/block.inc, line 37

Code

function block_patterns_get_arguments($action, $tag, $form_id, &$loop = FALSE) {

  // gives one dataset as an example how it looks like, while extract_all
  // extracts all
  if ($tag == 'block' && $action == PATTERNS_MODIFY) {
    $block_list = _block_rehash();
    if ($form_id == 'block_admin_display_form') {
      $blocks = array();
      foreach ($block_list as $key => $block) {
        array_push($blocks, $block);
      }
      foreach (array_keys(list_themes()) as $theme) {
        return array(
          $blocks,
          $theme,
        );
      }
    }
    elseif ($form_id == 'block_admin_configure') {
      foreach ($block_list as $key => $block) {
        return array(
          $block['module'],
          $block['delta'],
        );
      }
    }
    return array();
  }
  elseif ($tag == 'block_extract_all') {
    $loop = TRUE;
    $block_list = _block_rehash();
    $return = array();
    if ($form_id == 'block_admin_display_form') {
      $blocks = array();
      foreach ($block_list as $key => $block) {
        array_push($blocks, $block);
      }
      foreach (array_keys(list_themes()) as $theme) {
        array_push($return, array(
          $blocks,
          $theme,
        ));
      }
    }
    elseif ($form_id == 'block_admin_configure') {
      foreach ($block_list as $key => $block) {
        array_push($return, array(
          $block['module'],
          $block['delta'],
        ));
      }
    }
    return $return;
  }
}