You are here

shrinktheweb.module in ShrinkTheWeb 6

Same filename and directory in other branches
  1. 8 shrinktheweb.module
  2. 7 shrinktheweb.module

File

shrinktheweb.module
View source
<?php

/**
 * Implementation of hook_help() 
 */
function shrinktheweb_help($path, $arg) {
  switch ($path) {
    case 'admin/help#shrinktheweb':
      return '<p>' . t('You can find the latest help information for the ShrinkTheWeb module at !url .', array(
        '!url' => '<a href="http://drupal.org/node/1067900" target="_blank">http://drupal.org/node/1067900</a>',
      )) . '</p>';
  }
}

/**
 * Implementation of hook_permission().
 */
function shrinktheweb_perm() {
  return array(
    'administer ShrinkTheWeb settings',
  );
}

/**
 * Implementation of hook_theme()
 */
function shrinktheweb_theme($existing, $type, $theme, $path) {
  return array(
    'shrinktheweb_image' => array(
      'variables' => array(
        'url' => NULL,
        'options' => NULL,
      ),
    ),
  );
}

/**
* Implementation of hook_menu().
*/
function shrinktheweb_menu() {
  $items = array();
  $items['admin/settings/shrinktheweb'] = array(
    'title' => 'ShrinkTheWeb',
    'description' => 'Configure API settings such as public, private keys, thumbnails cache and other',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'shrinktheweb_admin_settings',
    ),
    'access arguments' => array(
      'administer ShrinkTheWeb settings',
    ),
    'file' => 'shrinktheweb.admin.inc',
  );
  $items['admin/settings/shrinktheweb/settings'] = array(
    'title' => 'Settings',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/settings/shrinktheweb/log'] = array(
    'title' => 'Log',
    'description' => 'Browse the request records',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'shrinktheweb_admin_log',
    ),
    'access arguments' => array(
      'administer ShrinkTheWeb settings',
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => 0,
    'file' => 'shrinktheweb.admin.inc',
  );
  return $items;
}

/**
 * Generates or returns the path/source of the thumbnail
 *
 * @param string $url The URL of the web page
 * @param array $options Overwrite the options set in admin config
 * @access public
 *
 * @return mixed Thumbnail path/source or FALSE
 */
function shrinktheweb_get_thumbnail($url, $options = array()) {
  module_load_include('inc', 'shrinktheweb', 'shrinktheweb.api');
  $sImageURL = shrinktheweb_getThumbnailURL($url, $options);
  return $sImageURL;
}

/**
 * Displays the thumbnail. 
 *
 * @param mixed $url
 * @param array $options. The attributes to apply to the thumbnail image.
 * @access public
 * @return mixed. Link with the image tag or FALSE on error.
 */
function theme_shrinktheweb_image($url, $options = array()) {
  $src = shrinktheweb_get_thumbnail($url);
  if ($src) {
    return l(theme('image', $src, $options['alt'], $options['title'], NULL, FALSE), $url, array(
      'html' => TRUE,
      'attributes' => array(
        'target' => '_blank',
      ),
    ));
  }
  return FALSE;
}

Functions

Namesort descending Description
shrinktheweb_get_thumbnail Generates or returns the path/source of the thumbnail
shrinktheweb_help Implementation of hook_help()
shrinktheweb_menu Implementation of hook_menu().
shrinktheweb_perm Implementation of hook_permission().
shrinktheweb_theme Implementation of hook_theme()
theme_shrinktheweb_image Displays the thumbnail.