You are here

function search_by_page_block in Search by Page 6

Implementation of hook_block().

File

./search_by_page.module, line 766
Main module file for Drupal module Search by Page.

Code

function search_by_page_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $ret = array();

      // Create one block per environment
      $envs = search_by_page_list_environments();
      foreach ($envs as $envid) {
        $envname = search_by_page_setting_get('environment_name', $envid, t('new'));
        if (module_exists('i18nstrings')) {
          $envname = i18nstrings('search_by_page:environment:name' . $envid, $envname);
        }
        $ret[$envid] = array(
          'info' => t('Search by page @environment', array(
            '@environment' => $envname,
          )),
        );
      }
      return $ret;
    case 'view':
      $blocktitle = search_by_page_setting_get('block_title', $delta, t('Search'));
      if (module_exists('i18nstrings')) {
        $blocktitle = i18nstrings('search_by_page:search_form:block_title' . $delta, $blocktitle);
      }
      return array(
        'subject' => $blocktitle,
        'content' => drupal_get_form('search_by_page_form', $delta, NULL, TRUE),
      );
  }
}