You are here

function shurly_block in ShURLy 6

File

./shurly.module, line 70
description http://www.youtube.com/watch?v=Qo7qoonzTCE

Code

function shurly_block($op = 'list', $delta = 0, $edit = array()) {

  // create a block to add URL
  switch ($op) {
    case 'list':
      $blocks['form'] = array(
        'info' => t('Short URL form'),
      );
      $blocks['bookmarklet'] = array(
        'info' => t('ShURLy bookmarklet'),
      );
      return $blocks;
    case 'view':

      // don't show the block when user is on the callback page
      if ($delta == 'form' && user_access('Create short URLs') && arg(0) != 'shurly') {
        $block = array(
          'subject' => t('Create a short URL'),
          'content' => drupal_get_form('shurly_create_form'),
        );
        return $block;
      }
      if ($delta == 'bookmarklet' && user_access('Create short URLs')) {
        drupal_add_css(drupal_get_path('module', 'shurly') . '/shurly.css');
        $block = array(
          'subject' => t('Bookmarklet'),
          'content' => t("<p>Drag this link to your bookmark bar to quickly create a short URL from any page: <a class=\"shurly-bookmarklet\" href=\"!jsurl\">!sitename</a><br />\nOr install the <a href=\"http://github.com/downloads/Lullabot/shurly/shurly.safariextz\">Safari browser extension</a>.</p>", array(
            '!jsurl' => "javascript:void(location.href='" . _surl('shurly', array(
              'absolute' => TRUE,
            )) . "&url='+encodeURIComponent(location.href))",
            '!sitename' => variable_get('site_name', 'Drupal'),
          )),
        );
        return $block;
      }
      break;
  }
}