示例#1
0
/**
 * Display individual price option
 */
function __tinypass_price_option_display($opt, TPPaySettings $ps, $sub = true, $subWidth = 380)
{
    $times = TPSiteSettings::$PERIOD_CHOICES;
    $enabled = 0;
    $default_price = '';
    $default_access_period = '';
    $default_access_period_type = '';
    if ($opt == '1') {
        $default_price = '1';
        $default_access_period = '1';
        $default_access_period_type = 'day';
    }
    $price = $ps->getPrice($opt, $default_price);
    $access_period = $ps->getAccessPeriod($opt, $default_access_period);
    $access_period_type = $ps->getAccessPeriodType($opt, $default_access_period_type);
    $caption = htmlspecialchars(stripslashes($ps->getCaption($opt)));
    $recur = "1 month" == $ps->getRecurring($opt);
    if ($opt == 1 || $ps->hasPriceConfig($opt)) {
        $enabled = 1;
    }
    $display = "display:none";
    if ($opt == '1' || $enabled) {
        $display = "";
    }
    ?>
	<table class="tinypass_price_options_form option_form option_form<?php 
    echo $opt;
    ?>
" style="<?php 
    echo $display;
    ?>
">
		<tr>
			<td width="100">
				<input type="hidden" id="<?php 
    echo "po_en{$opt}";
    ?>
" name="tinypass[<?php 
    echo "po_en{$opt}";
    ?>
]" value="<?php 
    echo $enabled;
    ?>
">
				<input type="text" size="8" maxlength="10" name="tinypass[<?php 
    echo "po_p{$opt}";
    ?>
]" value="<?php 
    echo $price;
    ?>
">
			</td>
			<td width="<?php 
    echo $subWidth;
    ?>
">
				<?php 
    if ($sub) {
        ?>
					<input class="recurring-opts-off" opt="<?php 
        echo $opt;
        ?>
" type="radio" value="0" name="tinypass[po_recur<?php 
        echo $opt;
        ?>
]" <?php 
        echo checked($recur, false);
        ?>
 autocomplete="false">
				<?php 
    }
    ?>
				<input type="text" size="5" maxlength="5" name="tinypass[<?php 
    echo "po_ap{$opt}";
    ?>
]" value="<?php 
    echo $access_period;
    ?>
" class="po_ap_opts<?php 
    echo $opt;
    ?>
">
				<?php 
    echo __tinypass_dropdown("tinypass[po_ap_type{$opt}]", $times, $access_period_type, array('class' => "po_ap_opts{$opt}"));
    ?>
				<?php 
    if ($sub) {
        ?>
					<span style="margin-left:30px">&nbsp;</span>
					<input class="recurring-opts-on" id="<?php 
        echo "po_recur{$opt}";
        ?>
" type="radio" name="tinypass[po_recur<?php 
        echo $opt;
        ?>
]" value="1 month" <?php 
        checked($recur);
        ?>
 opt="<?php 
        echo $opt;
        ?>
">
					<label for="<?php 
        echo "po_recur{$opt}";
        ?>
"><?php 
        _e("Monthly Subscription");
        ?>
</label>
				<?php 
    }
    ?>
			</td>
			<td width="270">
				<input type="text" size="20" maxlength="20" name="tinypass[<?php 
    echo "po_cap{$opt}";
    ?>
]" value="<?php 
    echo $caption;
    ?>
">
			</td>
		</tr>
	</table>
	<?php 
}