コード例 #1
0
function adinj_selection_box($name, $values, $type = "", $selected_value = NULL)
{
    $associative = false;
    if (!array_key_exists(0, $values)) {
        // Very naive test but works for me.
        $associative = true;
    }
    if ($selected_value == NULL) {
        $ops = adinj_options();
        $selected_value = $ops[$name];
    }
    echo "<select name='{$name}' id='{$name}'>";
    foreach ($values as $key => $value) {
        $option_value = $value;
        $display_value = $value;
        if ($associative) {
            $option_value = $key;
        }
        echo "<option value=\"{$option_value}\" ";
        if ("{$selected_value}" == "{$option_value}" || "{$selected_value}" == ADINJ_DISABLED && "{$option_value}" == 'd' || "{$selected_value}" == ADINJ_NA && "{$option_value}" == 'd' || "{$selected_value}" == ADINJ_RULE_DISABLED && "{$option_value}" == 'd' || "{$selected_value}" == ADINJ_ONLY_SHOW_IN && "{$option_value}" == 'o' || "{$selected_value}" == ADINJ_NEVER_SHOW_IN && "{$option_value}" == 'n') {
            echo 'selected="selected"';
        }
        $typetxt = $type;
        if (adinj_not_set($option_value)) {
            $typetxt = "";
        }
        if ("{$option_value}" === 'a') {
            $display_value = ADINJ_NA;
        }
        //TODO remove?
        if ("{$option_value}" === 'd') {
            $display_value = ADINJ_NA;
        }
        if ("{$option_value}" === 'o') {
            $display_value = ADINJ_ONLY_SHOW_IN;
        }
        if ("{$option_value}" === 'n') {
            $display_value = ADINJ_NEVER_SHOW_IN;
        }
        echo ">{$display_value} {$typetxt}</option>";
    }
    echo "</select>";
}
コード例 #2
0
function adinj_num_bottom_ads_to_insert($content_length, &$debug)
{
    if (adinj_excluded_by_tick_box('bottom_')) {
        return 0;
    }
    $ops = adinj_options();
    $prefix = adinj_get_current_page_type_prefix();
    $max_num_ads_to_insert = 0;
    if (is_single() || is_page()) {
        $max_num_ads_to_insert = 1;
    } else {
        global $adinj_total_bottom_ads_used;
        $max_num_ads_to_insert = $ops[$prefix . 'max_num_bottom_ads_per_page'] - $adinj_total_bottom_ads_used;
    }
    if ($max_num_ads_to_insert <= 0) {
        return 0;
    }
    if (adinj_ads_filtered_out('bottom', $debug)) {
        return 0;
    }
    $val = $ops[$prefix . 'bottom_ad_if_longer_than'];
    if (adinj_not_set($val) || adinj_true_if($content_length, '>', $val)) {
        return 1;
    }
    $debug .= "\nNo bottom ad because post length < {$val}";
    return 0;
}