Name

flag —

ATTRIBUTES

Attribute Pos. Req. Default Description
value
status
table
show
interpolate     0 interpolate output?
hide     0 Hide the tag return value?

DESCRIPTION

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

No examples are available at this time. We do consider this a problem and will try to supply some.

NOTES

AVAILABILITY

flag is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: code/SystemTag/flag.coretag
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: flag.coretag,v 1.5 2007-03-30 23:40:49 pajamian Exp $

UserTag flag                Order        type
UserTag flag                addAttr
UserTag flag                attrAlias    tables table
UserTag flag                attrAlias    flag type
UserTag flag                attrAlias    name type
UserTag flag                PosNumber    1
UserTag flag                Version      $Revision: 1.5 $
UserTag flag                MapRoutine   Vend::Interpolate::flag

Source: lib/Vend/Interpolate.pm
Lines: 1875

sub flag {
my($flag, $opt, $text) = @_;
$flag = lc $flag;

if(! $text) {
  ($flag, $text) = split /\s+/, $flag;
}
my $value = defined $opt->{value} ? $opt->{value} : 1;
my $fmt = $opt->{status} || '';
my @status;

#::logDebug("tag flag=$flag text=$text value=$value opt=". uneval_it($opt));
if($flag eq 'write' || $flag eq 'read') {
  my $arg = $opt->{table} || $text;
  $value = 0 if $flag eq 'read';
  my (@args) = Text::ParseWords::shellwords($arg);
  my $dbname;
  foreach $dbname (@args) {
    # Handle table:column:key
    $dbname =~ s/:.*//;
#::logDebug("tag flag write $dbname=$value");
    $Vend::WriteDatabase{$dbname} = $value;
  }
}
elsif($flag =~ /^transactions?/i) {
  my $arg = $opt->{table} || $text;
  my (@args) = Text::ParseWords::shellwords($arg);
  my $dbname;
  foreach $dbname (@args) {
    # Handle table:column:key
    $dbname =~ s/:.*//;
    $Vend::TransactionDatabase{$dbname} = $value;
    $Vend::WriteDatabase{$dbname} = $value;

    # we can't do anything else if in Safe
    next if $MVSAFE::Safe;

    # Now we close and reopen
    my $db = database_exists_ref($dbname)
      or next;
    if($db->isopen()) {
      # need to reopen in transactions mode. 
      $db->close_table();
      $db->suicide();
      $db = database_exists_ref($dbname);
      $db = $db->ref();
    }
    $Db{$dbname} = $db;
    $Sql{$dbname} = $db->dbh()
      if $db->can('dbh');
  }
}
elsif($flag eq 'commit' || $flag eq 'rollback') {
  my $arg = $opt->{table} || $text;
  $value = 0 if $flag eq 'rollback';
  my $method = $value ? 'commit' : 'rollback';
  my (@args) = Text::ParseWords::shellwords($arg);
  my $dbname;
  foreach $dbname (@args) {
    # Handle table:column:key
    $dbname =~ s/:.*//;
#::logDebug("tag commit $dbname=$value");
    my $db = database_exists_ref($dbname);
    next unless $db->isopen();
    next unless $db->config('Transactions');
    if( ! $db ) {
      logError("attempt to $method on unknown database: %s", $dbname);
      return undef;
    }
    if( ! $db->$method() ) {
      logError("problem doing $method for table: %s", $dbname);
      return undef;
    }
  }
}
elsif($flag eq 'checkhtml') {
  $Vend::CheckHTML = $value;
  @status = ("Set CheckHTML flag: %s", $value);
}
else {
  @status = ("Unknown flag operation '%s', ignored.", $flag);
  $status[0] = $opt->{status} if $opt->{status};
  logError( @status );
}
return '' unless $opt->{show};
$status[0] = $opt->{status} if $opt->{status};
return errmsg(@status);
}

AUTHORS

Interchange Development Group

SEE ALSO

DocBook! Interchange!