You are here

function scrolltext_block in ScrollText 6

Same name and namespace in other branches
  1. 5 scrolltext.module \scrolltext_block()

Implementation of hook_block().

File

./scrolltext.module, line 139
This module used for scrolling text from node title

Code

function scrolltext_block($op = 'list', $delta = 0) {
  global $user;
  if ($op == 'list') {
    $blocks[0]['info'] = 'ScrollText';
    return $blocks;
  }
  if ($op == 'view') {
    switch ($delta) {
      case 0:
        $block['subject'] = t('<none>');
        $block['content'] = '';
        $scrolltext_direction = variable_get('scrolltext_direction', 'Left');
        $scrolltext_behavior = variable_get('scrolltext_behavior', 'Scroll');
        $scrolltext_width = variable_get('scrolltext_width', '100%');
        $scrolltext_height = variable_get('scrolltext_height', '0');
        $scrolltext_format = variable_get('scrolltext_format', '');
        $scrolltext_speed = variable_get('scrolltext_speed', '10');
        $scrolltext_delay = variable_get('scrolltext_delay', '100');
        $scrolltext_nodetype = variable_get('scrolltext_nodetype', "'page','story'");
        $scrolltext_count = variable_get('scrolltext_count', '10');
        $sql = "SELECT n.title, n.nid FROM {node} n WHERE n.status = 1 and n.type IN ({$scrolltext_nodetype}) " . "ORDER BY n.created DESC LIMIT {$scrolltext_count}";
        $results = db_query($sql);
        if ($results) {
          $block['content'] = "<DIV ID='scrolltext'>" . "<MARQUEE DIRECTION='{$scrolltext_direction}' " . "BEHAVIOR='{$scrolltext_behavior}' " . "WIDTH='{$scrolltext_width}' ";
          if (strcmp($scrolltext_height, '0') !== 0) {
            $block['content'] .= "HEIGHT='{$scrolltext_height}' ";
          }
          $block['content'] .= "SCROLLAMOUNT='{$scrolltext_speed}' " . "SCROLLDELAY='{$scrolltext_delay}' " . ">";
          while ($data = db_fetch_object($results)) {
            $block['content'] .= "<font style='{$scrolltext_format}'>{$data->title}</font>";
            $block['content'] .= l(" Read more", "node/{$data->nid}") . str_repeat('&nbsp', 5);
            if ($scrolltext_direction == 'Up' or $scrolltext_direction == 'Down') {
              $block['content'] .= "<br />\n";
            }
          }
          $block['content'] .= '</MARQUEE></DIV>';
        }
        break;
    }
    return $block;
  }
}