You are here

function fasttoggle_link in Fasttoggle 7

Same name and namespace in other branches
  1. 5 fasttoggle.module \fasttoggle_link()
  2. 6 fasttoggle.module \fasttoggle_link()

Return a link.

Parameters

string $type: The type of object for which a link is wanted.

object $obj: The instance of the object (eg user ID)

int $teaser: Whether the link is to a teaser.

Return value

array The link render array.

File

./fasttoggle.module, line 244
Enables fast toggling of binary or not so binary settings.

Code

function fasttoggle_link($type, $obj, $teaser = FALSE) {
  $links = array();
  $options = fasttoggle_get_allowed_links($type, $obj);
  if (!empty($options)) {
    switch ($type) {
      case 'node':
        foreach (array_keys($options['fields']['status']['instances']) as $key) {
          $links['fasttoggle_' . $key] = fasttoggle($options, 'status', $key, $obj, FASTTOGGLE_FORMAT_LINK_ARRAY);
        }
        break;
      case 'comment':
        fasttoggle_load_comment($obj);
        foreach (array_keys($options['fields']['status']['instances']) as $key) {
          $links['fasttoggle_' . $key] = fasttoggle($options, 'status', $key, $obj, FASTTOGGLE_FORMAT_LINK_ARRAY);
        }
        break;

      // User is not one of the standard types for hook_link(). This
      // use enables adding of user links to a user profile.
      case 'user':
        if (!empty($options['fields']['status']['instances'])) {
          foreach (array_keys($options['fields']['status']['instances']) as $key) {
            $links['fasttoggle_' . $key] = fasttoggle($options, 'status', $key, $obj, FASTTOGGLE_FORMAT_LINK_ARRAY);
          }
        }
        break;
    }
  }
  return $links;
}