function buildZoneForm($aZone, $oComponent = null) { $form = new OA_Admin_UI_Component_Form("zoneform", "POST", $_SERVER['SCRIPT_NAME']); $form->forceClientValidation(true); $form->addElement('hidden', 'zoneid', $aZone['zoneid']); $form->addElement('hidden', 'affiliateid', $aZone['affiliateid']); buildChainSettingsFormSection($form, $aZone); if ($oComponent && method_exists($oComponent, 'extendZoneAdvancedForm')) { $oComponent->extendZoneAdvancedForm($form, $aZone); } buildDeliveryCappingFormSection($form, $GLOBALS['strCappingZone'], $aZone); buildAppendFormSection($form, $aZone); buildAlgorithmFormSection($form, $aZone); //we want submit to be the last element in its own separate section $form->addElement('controls', 'form-controls'); $form->addElement('submit', 'submit', $GLOBALS['strSaveChanges']); //set form values $form->setDefaults($aZone); $form->setDefaults(array('chaintype' => $aZone['chain'] == '' ? 0 : 1)); //appendinterstitial i appendpopup if ($appendid == $k) { return $form; } }
function buildCampaignForm($campaign, &$oComponent = null) { global $pref; $form = new OA_Admin_UI_Component_Form("campaignform", "POST", $_SERVER['SCRIPT_NAME']); $form->forceClientValidation(true); $form->addElement('hidden', 'campaignid', $campaign['campaignid']); $form->addElement('hidden', 'clientid', $campaign['clientid']); $form->addElement('hidden', 'expire_time', $campaign['expire_time']); $form->addElement('hidden', 'target_old', isset($campaign['target_value']) ? (int) $campaign['target_value'] : 0); $form->addElement('hidden', 'target_type_old', isset($campaign['target_type']) ? $campaign['target_type'] : ''); $form->addElement('hidden', 'weight_old', isset($campaign['weight']) ? (int) $campaign['weight'] : 0); $form->addElement('hidden', 'status_old', isset($campaign['status']) ? (int) $campaign['status'] : 1); $form->addElement('hidden', 'previousweight', isset($campaign["weight"]) ? $campaign["weight"] : ''); $form->addElement('hidden', 'previoustarget', isset($campaign["target"]) ? $campaign["target"] : ''); $form->addElement('hidden', 'previousactive', isset($campaign["active"]) ? $campaign["active"] : ''); $form->addElement('hidden', 'previousimpressions', isset($campaign["impressions"]) ? $campaign["impressions"] : ''); $form->addElement('hidden', 'previousclicks', isset($campaign["clicks"]) ? $campaign["clicks"] : ''); $form->addElement('hidden', 'previousconversions', isset($campaign["conversions"]) ? $campaign["conversions"] : ''); //campaign inactive note (if any) if (isset($campaign['status']) && $campaign['status'] != OA_ENTITY_STATUS_RUNNING) { $aReasons = getCampaignInactiveReasons($campaign); $form->addElement('custom', 'campaign-inactive-note', null, array('inactiveReason' => $aReasons), false); } //form sections $newCampaign = empty($campaign['campaignid']); $remnantEcpmEnabled = !empty($pref['campaign_ecpm_enabled']); $contractEcpmEnabled = !empty($pref['contract_ecpm_enabled']); buildBasicInformationFormSection($form, $campaign, $newCampaign, $remnantEcpmEnabled, $contractEcpmEnabled); buildDateFormSection($form, $campaign, $newCampaign); buildPricingFormSection($form, $campaign, $newCampaign, $remnantEcpmEnabled, $contractEcpmEnabled); buildPluggableFormSection($oComponent, 'afterPricingFormSection', $form, $campaign, $newCampaign); buildHighPriorityFormSection($form, $campaign, $newCampaign); buildLowAndExclusivePriorityFormSection($form, $campaign, $newCampaign); buildDeliveryCappingFormSection($form, $GLOBALS['strCappingCampaign'], $campaign, null, null, true, $newCampaign); buildMiscFormSection($form, $campaign, $newCampaign); //form controls $form->addElement('controls', 'form-controls'); $form->addElement('submit', 'submit', $GLOBALS['strSaveChanges']); //validation rules $translation = new OX_Translation(); $nameRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strName'])); $form->addRule('campaignname', $nameRequiredMsg, 'required'); $form->addFormRule('checkIfCampaignTypeSpecified'); $typeRequiredMsg = $translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strPricingModel'])); $form->addRule('revenue_type', $typeRequiredMsg, 'required'); // $form->addRule('impressions', 'TODO message', 'formattedNumber'); // $form->addRule('clicks', 'TODO message', 'formattedNumber'); // if ($conf['logging']['trackerImpressions']) { // $form->addRule('conversions', 'TODO message', 'formattedNumber'); // } // $form->addRule('weight', 'TODO message', 'wholeNumber-'); // $form->addRule('target_value', 'TODO message', 'wholeNumber-'); //set form values $form->setDefaults($campaign); $form->setDefaults(array('impressions' => !isset($campaign['impressions']) || $campaign['impressions'] == '' || $campaign['impressions'] < 0 ? '-' : $campaign['impressions'], 'clicks' => !isset($campaign['clicks']) || $campaign['clicks'] == '' || $campaign['clicks'] < 0 ? '-' : $campaign['clicks'], 'conversions' => !isset($campaign['conversions']) || $campaign['conversions'] == '' || $campaign['conversions'] < 0 ? '-' : $campaign['conversions'])); if (!empty($campaign['activate_date'])) { $oDate = new Date($campaign['activate_date']); $startDateSet = 't'; $startDateStr = $oDate->format('%d %B %Y '); } else { $startDateSet = 'f'; $startDateStr = ''; } if (!empty($campaign['expire_date'])) { $oDate = new Date($campaign['expire_date']); $endDateSet = 't'; $endDateStr = $oDate->format('%d %B %Y '); } else { $endDateSet = 'f'; $endDateStr = ''; } $form->setDefaults(array('campaign_type' => $newCampaign ? '' : OX_Util_Utils::getCampaignType($campaign['priority']), 'impr_unlimited' => isset($campaign["impressions"]) && $campaign["impressions"] >= 0 ? 'f' : 't', 'click_unlimited' => isset($campaign["clicks"]) && $campaign["clicks"] >= 0 ? 'f' : 't', 'conv_unlimited' => isset($campaign["conversions"]) && $campaign["conversions"] >= 0 ? 'f' : 't', 'startSet' => $startDateSet, 'endSet' => $endDateSet, 'start' => $startDateStr, 'end' => $endDateStr, 'priority' => $campaign['priority'] > '0' && $campaign['campaignid'] != '' ? 2 : $campaign['priority'], 'high_priority_value' => $campaign['priority'] > '0' ? $campaign['priority'] : 5, 'target_value' => !empty($campaign['target_value']) ? $campaign['target_value'] : '-', 'weight' => isset($campaign["weight"]) ? $campaign["weight"] : $pref['default_campaign_weight'], 'revenue_type' => isset($campaign["revenue_type"]) ? $campaign["revenue_type"] : MAX_FINANCE_CPM)); return $form; }