summaryNameField example


  protected function summaryQuery() {
    $this->ensureMyTable();
    // Add the field.     $this->base_alias = $this->query->addField($this->tableAlias, $this->realField);

    $this->summaryNameField();
    $this->summaryBasics();
  }

  /** * Adds the name field, which is the field displayed in summary queries. * * This is often used when the argument is numeric. */
  protected function summaryNameField() {
    // Add the 'name' field. For example, if this is a uid argument, the     // name field would be 'name' (i.e, the username).
// Add the field.       $this->base_alias = $this->query->addField($this->tableAlias, $this->realField);
      $this->query->setCountField($this->tableAlias, $this->realField);
    }
    else {
      // Add the field.       $formula = $this->getFormula();
      $this->base_alias = $this->query->addField(NULL, $formula$this->field . '_truncated');
      $this->query->setCountField(NULL, $formula$this->field, $this->field . '_truncated');
    }

    $this->summaryNameField();
    return $this->summaryBasics(FALSE);
  }

  /** * Get the formula for this argument. * * $this->ensureMyTable() MUST have been called prior to this. */
  public function getFormula() {
    $formula = "SUBSTRING($this->tableAlias.$this->realField, 1, " . intval($this->options['limit']) . ")";

    
if (empty($this->options['add_table']) || empty($this->view->many_to_one_tables[$field])) {
      $this->tableAlias = $this->query->ensureTable($this->table, $this->relationship, $join);
    }
    else {
      $this->tableAlias = $this->helper->summaryJoin();
    }

    // Add the field.     $this->base_alias = $this->query->addField($this->tableAlias, $this->realField);

    $this->summaryNameField();

    return $this->summaryBasics();
  }

  public function summaryArgument($data) {
    $value = $data->{$this->base_alias};
    if (empty($value)) {
      $value = 0;
    }

    return $value;
  }
Home | Imprint | This part of the site doesn't use cookies.