function _displayZoneEntitySelectionCell($entity, $entityId, $aOtherEntities, $entityIdName, $aSavedEntities, $autoSubmit, $pageName, &$tabIndex) { global $phpAds_TextDirection; $onChange = $autoSubmit ? " onChange='this.form.submit();'" : ''; $submitIcon = $autoSubmit ? '' : " <input type='hidden' name='action' value='set'><input id='link_submit' name='submitimage' id='submitimage' type='image' src='" . OX::assetPath() . "/images/{$phpAds_TextDirection}/go_blue.gif' border='0' tabindex='" . $tabIndex++ . "'>"; $tabInfo = " tabindex='" . $tabIndex++ . "'"; $entityIcon = MAX_getEntityIcon($entity); echo "\n<td>\n<form name='zonetypeselection' method='get' action='{$pageName}'>"; foreach ($aSavedEntities as $savedEntityName => $savedEntityId) { echo "\n<input type='hidden' name='{$savedEntityName}' value='{$savedEntityId}'>"; } echo "\n <img src='{$entityIcon}' align='absmiddle'> \n <select name='{$entityIdName}'{$onChange}{$tabInfo}>"; // Show an empty value in the dropdown if none is selected if (empty($entityId)) { switch ($entity) { case 'advertiser': $description = "-- {$GLOBALS['strSelectAdvertiser']} --"; break; case 'placement': $description = "-- {$GLOBALS['strSelectPlacement']} --"; break; case 'ad': $description = "-- {$GLOBALS['strSelectAd']} --"; break; default: $description = ''; } echo "\n <option value='' selected>{$description}</option>"; } $aOtherEntities = _multiSort($aOtherEntities, 'name', 'advertiser_id'); foreach ($aOtherEntities as $aOtherEntity) { switch ($entity) { case 'advertiser': $otherEntityId = $aOtherEntity['advertiser_id']; break; case 'placement': $otherEntityId = $aOtherEntity['placement_id']; break; case 'ad': $otherEntityId = $aOtherEntity['ad_id']; break; } $selected = $otherEntityId == $entityId ? ' selected' : ''; $adsCount = ''; if ($entity == 'placement') { $aParams = array('placement_id' => $otherEntityId); $aParams += MAX_getLinkedAdParams($GLOBALS['zoneId']); $doCampaign = OA_Dal::factoryDO('campaigns'); $doCampaign->campaignid = $otherEntityId; $doCampaign->find(); $doCampaign->fetch(); if ($doCampaign->type == DataObjects_Campaigns::CAMPAIGN_TYPE_DEFAULT) { $translation = new OX_Translation(); $aStringParams["bannerCount"] = count(Admin_DA::getAds($aParams)); $translated = $translation->translate($GLOBALS['strWithXBanners'], $aStringParams); $adsCount = "(" . $translated . ")"; } } $name = MAX_buildName($otherEntityId, $aOtherEntity['name']); echo "\n <option value='{$otherEntityId}'{$selected}>" . $name . " {$adsCount}</option>"; } echo "\n </select>\n {$submitIcon}\n</form>\n</td>"; }
function MAX_addLinkedAdsToZone($zoneId, $placementId) { $aParams = MAX_getLinkedAdParams($zoneId); $aParams['placement_id'] = $placementId; $aAds = Admin_DA::getAds($aParams); // FIXME $aLinkedAds = Admin_DA::getAdZones(array('zone_id' => $zoneId), false, 'ad_id'); foreach ($aAds as $adId => $aAd) { if (!isset($aLinkedAds[$adId])) { $ret = Admin_DA::addAdZone(array('zone_id' => $zoneId, 'ad_id' => $adId)); if (PEAR::isError($ret)) { return false; } } } return true; }
// Message echo "<br>"; echo "<div class='errormessage'><img class='errormessage' src='" . OX::assetPath() . "/images/errormessage.gif' align='absmiddle'>"; echo "<span class='tab-r'>{$GLOBALS['strUnableToLinkBanner']}</span><br><br>{$GLOBALS['strErrorLinkingBanner']} <br />" . $result->message . "</div><br>"; } MAX_displayPlacementAdSelectionViewForm($publisherId, $zoneId, $view, $pageName, $tabIndex, $aOtherZones); $aParams = MAX_getLinkedAdParams($zoneId); if ($view == 'placement') { $aDirectLinkedAds = Admin_DA::getAdZones(array('zone_id' => $zoneId), true, 'ad_id'); $aOtherAdvertisers = Admin_DA::getAdvertisers($aParams + array('agency_id' => $agencyId), false); $aOtherPlacements = !empty($advertiserId) ? Admin_DA::getPlacements($aParams + array('advertiser_id' => $advertiserId), false) : null; $aZonesPlacements = Admin_DA::getPlacementZones(array('zone_id' => $zoneId), true, 'placement_id'); MAX_displayZoneEntitySelection('placement', $aOtherAdvertisers, $aOtherPlacements, null, $advertiserId, $placementId, $adId, $publisherId, $zoneId, $GLOBALS['strSelectCampaignToLink'], $pageName, $tabIndex); if (!empty($aZonesPlacements)) { $aParams = array('placement_id' => implode(',', array_keys($aZonesPlacements))); $aParams += MAX_getLinkedAdParams($zoneId); } else { $aParams = null; } MAX_displayLinkedPlacementsAds($aParams, $publisherId, $zoneId, $hideInactive, $showMatchingAds, $pageName, $tabIndex, $aDirectLinkedAds); } elseif ($view == 'ad') { $aOtherAdvertisers = Admin_DA::getAdvertisers($aParams + array('agency_id' => $agencyId), false); $aOtherPlacements = !empty($advertiserId) ? Admin_DA::getPlacements($aParams + array('advertiser_id' => $advertiserId), false) : null; $aOtherAds = !empty($placementId) ? Admin_DA::getAds($aParams + array('placement_id' => $placementId), false) : null; $aAdsZones = Admin_DA::getAdZones(array('zone_id' => $zoneId), true, 'ad_id'); MAX_displayZoneEntitySelection('ad', $aOtherAdvertisers, $aOtherPlacements, $aOtherAds, $advertiserId, $placementId, $adId, $publisherId, $zoneId, $GLOBALS['strSelectBannerToLink'], $pageName, $tabIndex); $aParams = !empty($aAdsZones) ? array('ad_id' => implode(',', array_keys($aAdsZones))) : null; MAX_displayLinkedAdsPlacements($aParams, $publisherId, $zoneId, $hideInactive, $showParentPlacements, $pageName, $tabIndex); } ?>