You are here

class flag_handler_argument_content_id in Flag 6.2

Same name and namespace in other branches
  1. 6 includes/flag_handler_argument_content_id.inc \flag_handler_argument_content_id
  2. 7.2 includes/flag_handler_argument_content_id.inc \flag_handler_argument_content_id

Handler to accept an argument of the content ID of any object.

Hierarchy

Expanded class hierarchy of flag_handler_argument_content_id

1 string reference to 'flag_handler_argument_content_id'
flag_views_data in includes/flag.views.inc
Implements hook_views_data().

File

includes/flag_handler_argument_content_id.inc, line 13
Contains the content ID argument handler.

View source
class flag_handler_argument_content_id extends views_handler_argument_numeric {

  /**
   * Returns the flag object associated with our argument.
   *
   * An argument is in some relationship. This function reaches out for this
   * relationship and reads its 'flag' option, which holds the flag name.
   */
  function get_flag() {
    return $this->view->relationship[$this->options['relationship']]
      ->get_flag();
  }

  /**
   * Override the behavior of title(). Get the title of the appropriate objects.
   */
  function title_query() {
    if (!($flag = $this
      ->get_flag())) {
      return array();

      // Error message is printed by get_flag().
    }
    $views_info = $flag
      ->get_views_info();
    $titles = array();
    $placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
    $result = db_query("SELECT o." . $views_info['title field'] . " FROM {" . $views_info['views table'] . "} o WHERE o." . $views_info['join field'] . " IN ({$placeholders})", $this->value);
    while ($title = db_fetch_object($result)) {
      $titles[] = check_plain($title->{$views_info}['title field']);
    }
    return $titles;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
flag_handler_argument_content_id::get_flag function Returns the flag object associated with our argument.
flag_handler_argument_content_id::title_query function Override the behavior of title(). Get the title of the appropriate objects.