Esempio n. 1
0
function buildZoneForm($zone)
{
    global $conf;
    // Initialise Ad  Networks
    $oAdNetworks = new OA_Central_AdNetworks();
    $form = new OA_Admin_UI_Component_Form("zoneform", "POST", $_SERVER['PHP_SELF']);
    $form->forceClientValidation(true);
    $form->addElement('hidden', 'zoneid', $zone['zoneid']);
    $form->addElement('hidden', 'affiliateid', $zone['affiliateid']);
    $form->addElement('header', 'zone_basic_info', $GLOBALS['strBasicInformation']);
    $form->addElement('text', 'zonename', $GLOBALS['strName']);
    $form->addElement('text', 'description', $GLOBALS['strDescription']);
    $form->addElement('select', 'oac_category_id', $GLOBALS['strCategory'], $oAdNetworks->getCategoriesSelect());
    //zone type group
    $zoneTypes[] = $form->createElement('radio', 'delivery', '', "<img src='" . OX::assetPath() . "/images/icon-zone.gif' align='absmiddle'>&nbsp;" . $GLOBALS['strBannerButtonRectangle'], phpAds_ZoneBanner, array('id' => 'delivery-b', 'onClick' => 'phpAds_formEnableSize();', 'onChange' => 'oa_hide("warning_change_zone_type");'));
    if ($conf['oxInvocationTags']['isAllowedAdlayer'] || $zone['delivery'] == phpAds_ZoneInterstitial) {
        $zoneTypes[] = $form->createElement('radio', 'delivery', '', "<img src='" . OX::assetPath() . "/images/icon-interstitial.gif' align='absmiddle'>&nbsp;" . $GLOBALS['strInterstitial'], phpAds_ZoneInterstitial, array('id' => 'delivery-i', 'onClick' => 'phpAds_formEnableSize();', 'onChange' => 'oa_hide("warning_change_zone_type");'));
    }
    if ($conf['oxInvocationTags']['isAllowedPopup'] || $zone['delivery'] == phpAds_ZonePopup) {
        $zoneTypes[] = $form->createElement('radio', 'delivery', '', "<img src='" . OX::assetPath() . "/images/icon-popup.gif' align='absmiddle'>&nbsp;" . $GLOBALS['strPopup'], phpAds_ZonePopup, array('id' => 'delivery-p', 'onClick' => 'phpAds_formEnableSize();', 'onChange' => 'oa_hide("warning_change_zone_type");'));
    }
    $zoneTypes[] = $form->createElement('radio', 'delivery', '', "<img src='" . OX::assetPath() . "/images/icon-textzone.gif' align='absmiddle'>&nbsp;" . $GLOBALS['strTextAdZone'], phpAds_ZoneText, array('id' => 'delivery-t', 'onClick' => 'phpAds_formDisableSize();', 'onChange' => 'oa_hide("warning_change_zone_type");'));
    $zoneTypes[] = $form->createElement('radio', 'delivery', '', "<img src='" . OX::assetPath() . "/images/icon-zone-email.gif' align='absmiddle'>&nbsp;" . $GLOBALS['strEmailAdZone'], MAX_ZoneEmail, array('id' => 'delivery-e', 'onClick' => 'phpAds_formEnableSize();', 'onChange' => 'oa_hide("warning_change_zone_type");'));
    if (!empty($conf['allowedBanners']['video'])) {
        $zoneTypes[] = $form->createElement('radio', 'delivery', '', "<img src='" . OX::assetPath() . "/images/icon-zone-video-instream.png' align='absmiddle'>&nbsp;" . $GLOBALS['strZoneVideoInstream'], OX_ZoneVideoInstream, array('id' => 'delivery-vi', 'onClick' => 'phpAds_formDisableSize();', 'onChange' => 'oa_hide("warning_change_zone_type");'));
        $zoneTypes[] = $form->createElement('radio', 'delivery', '', "<img src='" . OX::assetPath() . "/images/icon-zone-video-overlay.png' align='absmiddle'>&nbsp;" . $GLOBALS['strZoneVideoOverlay'], OX_ZoneVideoOverlay, array('id' => 'delivery-vo', 'onClick' => 'phpAds_formDisableSize();', 'onChange' => 'oa_hide("warning_change_zone_type");'));
    }
    $form->addGroup($zoneTypes, 'zone_types', $GLOBALS['strZoneType'], "<br/>");
    //size
    global $phpAds_IAB;
    switch ($zone['delivery']) {
        case phpAds_ZoneText:
        case OX_ZoneVideoInstream:
        case OX_ZoneVideoOverlay:
            $sizeDisabled = true;
            $zone['width'] = '*';
            $zone['height'] = '*';
            break;
        default:
            $sizeDisabled = false;
            break;
    }
    $aDefaultSize['radio'] = $form->createElement('radio', 'sizetype', '', '', 'default', array('id' => 'size-d'));
    foreach (array_keys($phpAds_IAB) as $key) {
        $iabSizes[$phpAds_IAB[$key]['width'] . "x" . $phpAds_IAB[$key]['height']] = $GLOBALS['strIab'][$key];
    }
    $iabSizes['-'] = $GLOBALS['strCustom'];
    $aDefaultSize['select'] = $form->createElement('select', 'size', null, $iabSizes, array('onchange' => 'phpAds_formSelectSize(this); oa_sizeChangeUpdateMessage("warning_change_zone_size");', 'class' => 'medium'));
    $aCustomSize['radio'] = $form->createElement('radio', 'sizetype', '', '', 'custom', array('id' => 'size-c'));
    $aCustomSize['width'] = $form->createElement('text', 'width', $GLOBALS['strWidth'] . ':', array('onkeydown' => 'phpAds_formEditSize();', 'onChange' => 'oa_sizeChangeUpdateMessage("warning_change_zone_size");'));
    $aCustomSize['width']->setSize(5);
    $aCustomSize['height'] = $form->createElement('text', 'height', $GLOBALS['strHeight'] . ':', array('onkeydown' => 'phpAds_formEditSize();', 'onChange' => 'oa_sizeChangeUpdateMessage("warning_change_zone_size");'));
    $aCustomSize['height']->setSize(5);
    $sizeTypes['default'] = $form->createElement('group', 'defaultSizeG', null, $aDefaultSize, null, false);
    $sizeTypes['custom'] = $form->createElement('group', 'customSizeG', null, $aCustomSize, null, false);
    //disable fields if necessary
    if ($sizeDisabled) {
        $aDefaultSize['radio']->setAttribute('disabled', $sizeDisabled);
        $aDefaultSize['select']->setAttribute('disabled', $sizeDisabled);
        $aCustomSize['radio']->setAttribute('disabled', $sizeDisabled);
        $aCustomSize['width']->setAttribute('disabled', $sizeDisabled);
        $aCustomSize['height']->setAttribute('disabled', $sizeDisabled);
    }
    $form->addGroup($sizeTypes, 'size_types', $GLOBALS['strSize'], "<br/>");
    $form->addElement('textarea', 'comments', $GLOBALS['strComments']);
    $form->addElement('controls', 'form-controls');
    $form->addElement('submit', 'submit', $GLOBALS['strSaveChanges']);
    //validation rules
    $translation = new OX_Translation();
    $urlRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strName']));
    $form->addRule('zonename', $urlRequiredMsg, 'required');
    /*
    TODO
    max_formSetRequirements('width', '<?php echo addslashes($strWidth); ?>', true, 'number*');
    max_formSetRequirements('height', '<?php echo addslashes($strHeight); ?>', true, 'number*');
    */
    //set form values
    $form->setDefaults($zone);
    //sizes radio
    if (phpAds_sizeExists($zone['width'], $zone['height'])) {
        $size = $zone['width'] . "x" . $zone['height'];
        $sizeType = 'default';
    } else {
        $size = "-";
        $sizeType = 'custom';
    }
    $form->setDefaults(array('size' => $size, 'sizetype' => $sizeType));
    return $form;
}
Esempio n. 2
0
    echo "&nbsp;<img src='images/icon-popup.gif' align='absmiddle'>&nbsp;" . $strPopup . "</td></tr>";
}
echo "<tr><td><input type='radio' name='delivery' value='" . phpAds_ZoneText . "'" . ($zone['delivery'] == phpAds_ZoneText ? ' CHECKED' : '') . " onClick='phpAds_formDisableSize();' tabindex='" . $tabindex++ . "'>";
echo "&nbsp;<img src='images/icon-textzone.gif' align='absmiddle'>&nbsp;" . $strTextAdZone . "</td></tr>";
echo "</table></td></tr>";
if ($zone['delivery'] == phpAds_ZoneText) {
    $sizedisabled = ' disabled';
    $zone['width'] = '*';
    $zone['height'] = '*';
} else {
    $sizedisabled = '';
}
echo "<tr><td><img src='images/spacer.gif' height='1' width='100%'></td>";
echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
echo "<tr><td width='30'>&nbsp;</td><td width='200' valign='top'><br>" . $strSize . "</td><td>";
$exists = phpAds_sizeExists($zone['width'], $zone['height']);
echo "<table><tr><td>";
echo "<input type='radio' name='sizetype' value='default'" . ($exists ? ' CHECKED' : '') . $sizedisabled . " tabindex='" . $tabindex++ . "'>&nbsp;";
echo "<select name='size' onchange='phpAds_formSelectSize(this)'" . $sizedisabled . " tabindex='" . $tabindex++ . "'>";
foreach (array_keys($phpAds_IAB) as $key) {
    if ($phpAds_IAB[$key]['width'] == $zone['width'] && $phpAds_IAB[$key]['height'] == $zone['height']) {
        echo "<option value='" . $phpAds_IAB[$key]['width'] . "x" . $phpAds_IAB[$key]['height'] . "' selected>" . $key . "</option>";
    } else {
        echo "<option value='" . $phpAds_IAB[$key]['width'] . "x" . $phpAds_IAB[$key]['height'] . "'>" . $key . "</option>";
    }
}
echo "<option value='-'" . (!$exists ? ' SELECTED' : '') . ">" . $strCustom . "</option>";
echo "</select>";
echo "</td></tr><tr><td>";
echo "<input type='radio' name='sizetype' value='custom'" . (!$exists ? ' CHECKED' : '') . $sizedisabled . " onclick='phpAds_formEditSize()' tabindex='" . $tabindex++ . "'>&nbsp;";
echo $strWidth . ": <input class='flat' size='5' type='text' name='zwidth' value='" . (isset($zone["width"]) ? $zone["width"] : '') . "'" . $sizedisabled . " onkeydown='phpAds_formEditSize()' onBlur='phpAds_formUpdate(this);' tabindex='" . $tabindex++ . "'>";