本文整理汇总了PHP中Date::addSpan方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::addSpan方法的具体用法?PHP Date::addSpan怎么用?PHP Date::addSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::addSpan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLinks
public function getLinks()
{
$oDate = new Date($this->oStart);
$oNow = new Date();
$aLinks = array();
$baseUrl = parent::getUrl(false);
$date = $oDate->format('%Y-%m');
$aLinks['up'] = array('label' => $date, 'url' => $this->appendToUrl($baseUrl, 'month=' . $date));
$oDate->subtractSpan(new Date_Span('1-0-0-0'));
$date = $oDate->format('%Y-%m-%d');
$aLinks['prev'] = array('label' => '< ' . $date, 'url' => $this->appendToUrl($baseUrl, 'day=' . $date));
$oDate->addSpan(new Date_Span('2-0-0-0'));
$date = $oDate->format('%Y-%m-%d');
$aLinks['next'] = array('label' => $date . ' >');
if ($oNow->after($oDate)) {
$aLinks['next']['url'] = $this->appendToUrl($baseUrl, 'day=' . $date);
}
return $aLinks;
}
示例2: manageCampaigns
//.........这里部分代码省略.........
$report .= $message . "\n";
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignid = $aCampaign['campaign_id'];
$doCampaigns->find();
$doCampaigns->fetch();
$doCampaigns->status = OA_ENTITY_STATUS_EXPIRED;
$result = $doCampaigns->update();
if ($result == false) {
return MAX::raiseError($rows, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
}
phpAds_userlogSetUser(phpAds_userMaintenance);
phpAds_userlogAdd(phpAds_actionDeactiveCampaign, $aCampaign['campaign_id']);
} else {
// The campaign wasn't disabled based on the end
// date, to it *might* possibly be disabled "soon"...
$canExpireSoon = true;
}
}
if ($disableReason) {
// The campaign was disabled, so send the appropriate
// message to the campaign's contact
$query = "\n SELECT\n bannerid AS advertisement_id,\n description AS description,\n alt AS alt,\n url AS url\n FROM\n " . $this->oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table']['banners'], true) . "\n WHERE\n campaignid = {$aCampaign['campaign_id']}";
OA::debug(" - Getting the advertisements for campaign ID {$aCampaign['campaign_id']}", PEAR_LOG_DEBUG);
$rsResultAdvertisement = $this->oDbh->query($query);
if (PEAR::isError($rsResultAdvertisement)) {
return MAX::raiseError($rsResultAdvertisement, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
}
while ($advertisementRow = $rsResultAdvertisement->fetchRow()) {
$advertisements[$advertisementRow['advertisement_id']] = array($advertisementRow['description'], $advertisementRow['alt'], $advertisementRow['url']);
}
if ($aCampaign['send_activate_deactivate_email'] == 't') {
OA::debug(" - Sending campaign deactivated email ", PEAR_LOG_DEBUG);
$oEmail->sendCampaignActivatedDeactivatedEmail($aCampaign['campaign_id'], $disableReason);
// Also send campaignDeliveryEmail for the campaign we just deactivated.
$doClients = OA_Dal::staticGetDO('clients', $aCampaign['advertiser_id']);
$aAdvertiser = $doClients->toArray();
OA::debug(" - Sending campaign delivery email ", PEAR_LOG_DEBUG);
$oStart = new Date($aAdvertiser['reportlastdate']);
$oEnd = new Date($oDate);
// Set end date to tomorrow so we get stats for today.
$oEnd->addSpan(new Date_Span('1-0-0-0'));
$oEmail->sendCampaignDeliveryEmail($aAdvertiser, $oStart, $oEnd, $aCampaign['campaign_id']);
}
} else {
if ($canExpireSoon) {
// The campaign has NOT been deactivated - test to see if it will
// be deactivated "soon", and send email(s) warning of this as required
OA::debug(" - Sending campaign 'soon deactivated' email ", PEAR_LOG_DEBUG);
$oEmail->sendCampaignImpendingExpiryEmail($oDate, $aCampaign['campaign_id']);
}
}
} elseif (!empty($aCampaign['start'])) {
// The campaign is awaiting activation and has a valid start date, stored in UTC
$oStartDate = new Date($aCampaign['start']);
$oStartDate->setTZByID('UTC');
// Find out if there are any impression, click or conversion targets for
// the campaign (i.e. if the target values are > 0)
$remainingImpressions = 0;
$remainingClicks = 0;
$remainingConversions = 0;
if ($aCampaign['targetimpressions'] > 0 || $aCampaign['targetclicks'] > 0 || $aCampaign['targetconversions'] > 0) {
OA::debug(" - The campaign ID " . $aCampaign['campaign_id'] . " has an impression, click and/or conversion target, requesting impressions so far", PEAR_LOG_DEBUG);
$query = "\n SELECT\n SUM(dia.impressions) AS impressions,\n SUM(dia.clicks) AS clicks,\n SUM(dia.conversions) AS conversions\n FROM\n " . $this->oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table']['data_intermediate_ad'], true) . " AS dia,\n " . $this->oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table']['banners'], true) . " AS b\n WHERE\n dia.ad_id = b.bannerid\n AND b.campaignid = {$aCampaign['campaign_id']}";
$rsResultInner = $this->oDbh->query($query);
$valuesRow = $rsResultInner->fetchRow();
// Set the remaining impressions, clicks and conversions for the campaign
$remainingImpressions = $aCampaign['targetimpressions'] - $valuesRow['impressions'];
$remainingClicks = $aCampaign['targetclicks'] - $valuesRow['clicks'];
$remainingConversions = $aCampaign['targetconversions'] - $valuesRow['conversions'];
}
// In order for the campaign to be activated, need to test:
// 1) That there is no impression target (<= 0), or, if there is an impression target (> 0),
// then there must be remaining impressions to deliver (> 0); and
// 2) That there is no click target (<= 0), or, if there is a click target (> 0),
// then there must be remaining clicks to deliver (> 0); and
// 3) That there is no conversion target (<= 0), or, if there is a conversion target (> 0),
// then there must be remaining conversions to deliver (> 0)
if (($aCampaign['targetimpressions'] <= 0 || $aCampaign['targetimpressions'] > 0 && $remainingImpressions > 0) && ($aCampaign['targetclicks'] <= 0 || $aCampaign['targetclicks'] > 0 && $remainingClicks > 0) && ($aCampaign['targetconversions'] <= 0 || $aCampaign['targetconversions'] > 0 && $remainingConversions > 0)) {
$message = "- Passed campaign start time of '" . $oStartDate->getDate() . " UTC" . "': Activating campaign ID {$aCampaign['campaign_id']}: {$aCampaign['campaign_name']}";
OA::debug($message, PEAR_LOG_INFO);
$report .= $message . "\n";
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignid = $aCampaign['campaign_id'];
$doCampaigns->find();
$doCampaigns->fetch();
$doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
$result = $doCampaigns->update();
if ($result == false) {
return MAX::raiseError($rows, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
}
phpAds_userlogSetUser(phpAds_userMaintenance);
phpAds_userlogAdd(phpAds_actionActiveCampaign, $aCampaign['campaign_id']);
if ($aCampaign['send_activate_deactivate_email'] == 't') {
OA::debug(" - Sending activation email for campaign ID " . $aCampaign['campaign_id'], PEAR_LOG_DEBUG);
$oEmail->sendCampaignActivatedDeactivatedEmail($aCampaign['campaign_id']);
}
}
}
}
}
示例3: Date
/**
* Build the internal arrays that contain data about the calculated holidays
*
* @access protected
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
*/
function _buildHolidays()
{
/**
* New Year's Day
*/
$this->_addHoliday('newYearsDay', $this->_year . '-01-01', 'New Year\'s Day');
/**
* Epiphanias
*/
$this->_addHoliday('epiphany', $this->_year . '-01-06', 'Epiphany');
/**
* Easter Sunday
*/
$easterDate = Date_Holidays_Driver_Sweden::calcEaster($this->_year);
$this->_addHoliday('easter', $easterDate, 'Easter Sunday');
/**
* Good Friday / Black Friday
*/
$goodFridayDate = new Date($easterDate);
$goodFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'));
$this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
/**
* Easter Monday
*/
$this->_addHoliday('easterMonday', $easterDate->getNextDay(), 'Easter Monday');
/**
* May Day
*/
$this->_addHoliday('mayDay', $this->_year . '-05-01', 'May Day');
/**
* Pentecost (determines Whit Monday, Ascension Day and Feast of Corpus Christi)
*/
$pentecostDate = new Date($easterDate);
$pentecostDate->addSpan(new Date_Span('49, 0, 0, 0'));
$this->_addHoliday('pentecost', $pentecostDate, 'Pentecost');
/**
* Ascension Day
*/
$ascensionDayDate = new Date($pentecostDate);
$ascensionDayDate->subtractSpan(new Date_Span('10, 0, 0, 0'));
$this->_addHoliday('ascensionDay', $ascensionDayDate, 'Ascension Day');
/**
* Swedish National Day and the Swedish Flag's Day
*/
$this->_addHoliday('swedenNationalDay', $this->_year . '-06-06', 'Swedish National Day and the Swedish Flag\'s Day');
/**
* Midsummer
* Saturday past 20th, June
*/
$juneDate = new Date($this->_year . '-06-20');
$dayOfWeek = $juneDate->getDayOfWeek();
$juneDate->addSpan(new Date_Span(sprintf('%d, 0, 0, 0', 6 - $dayOfWeek)));
$midSummerDate = $juneDate;
$this->_addHoliday('midSummer', $midSummerDate, 'Midsummer Day');
/**
* Midsummer Eve
* Day before Midsummer.
*/
$this->_addHoliday('midSummerEve', $midSummerDate->getPrevDay(), 'Midsummer Eve');
/**
* All Saints' Day
*/
$saintspanDate = new Date($this->_year . '-10-31');
$dayOfWeek = $saintspanDate->getDayOfWeek();
$saintspanDate->addSpan(new Date_Span(sprintf('%d, 0, 0, 0', 6 - $dayOfWeek)));
$allSaintsDate = $saintspanDate;
$this->_addHoliday('allSaintsDay', $allSaintsDate, 'All Saints\' Day');
/**
* Christmas Eve
*/
$this->_addHoliday('xmasEve', $this->_year . '-12-24', 'Christmas Eve');
/**
* Christmas day
*/
$this->_addHoliday('xmasDay', $this->_year . '-12-25', 'Christmas Day');
/**
* Boxing day
*/
$this->_addHoliday('boxingDay', $this->_year . '-12-26', 'Boxing Day');
/**
* New Year's Eve
*/
$this->_addHoliday('newYearsEve', $this->_year . '-12-31', 'New Year\'s Eve');
if (Date_Holidays::errorsOccurred()) {
return Date_Holidays::getErrorStack();
}
return true;
}
示例4:
printf("Actual date: %s\n", $date->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('0:00:00:05'));
printf("Subtracting 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('0:00:20:00'));
printf("Subtracting 20 minutes: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('0:10:00:00'));
printf("Subtracting 10 hours: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('3:00:00:00'));
printf("Subtracting 3 days: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->subtractSpan(new Date_Span('3:10:20:05'));
printf("Subtracting 3 days, 10 hours, 20 minutes and 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->addSpan(new Date_Span('0:00:00:05'));
printf("Adding 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->addSpan(new Date_Span('0:00:20:00'));
printf("Adding 20 minutes: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->addSpan(new Date_Span('0:10:00:00'));
printf("Adding 10 hours: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->addSpan(new Date_Span('3:00:00:00'));
printf("Adding 3 days: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
$tmp->copy($date);
$tmp->addSpan(new Date_Span('3:10:20:05'));
printf("Adding 3 days, 10 hours, 20 minutes and 5 seconds: %s\n", $tmp->getDate(DATE_FORMAT_ISO));
示例5: getDatesArray
/**
* A method to calculate the range of dates that a statistics screen needs to display.
*
* Returns an array of values where:
*
* - If "week" or "day" is the breakdown, array is of days, indexed by "YYYY-MM-DD",
* and formatted using the user's local format for days.
*
* - If "month" is the breakdown, array is of months, indexed by "YYYY-MM",
* and formatted using the user's local format for months and days.
*
* - If "dow" is the breakdown, array is of days of the week, indexed by the integers
* 0 to 6, and formatted with the user's local weekday names.
*
* - If "hour" is the breakdown, array is of hours of the day, indexed by the integers
* 0 to 23, and formatted in the format "00:00 - 00:59", "01:00 01:59", etc.
*
* @param array $aDates An array of the start and end dates in use by the day
* span selector element, if set.
* @param string $breakdown The breakdown type in use. One of "week", "day", "month",
* "dow" or "hour".
* @param PEAR::Date $oStatsStartDate A date object representing the first day of statistics
* that are available.
* @return array The array, as described above.
*/
function getDatesArray($aDates, $breakdown, $oStatsStartDate)
{
// Does the day span selector element have dates set?
if ($aDates['day_begin'] && $aDates['day_end'] || $aDates['period_start'] && $aDates['period_end']) {
if ($aDates['day_begin'] && $aDates['day_end']) {
// Use the dates given by the day span selector element
$oStartDate = new Date($aDates['day_begin']);
$oEndDate = new Date($aDates['day_end']);
} else {
// Use the dates given by the period_start and period_end
$oStartDate = new Date($aDates['period_start']);
$oEndDate = new Date($aDates['period_end']);
}
// Adjust end date to be now, if it's in the future
if ($oEndDate->isFuture()) {
$oEndDate = new Date();
$aDates['day_end'] = new Date();
$aDates['day_end'] = $aDates['day_end']->format('%Y-%m-%d');
}
} else {
// Use the dates given by the statistics date limitation
// and now
$oStartDate = new Date();
$oStartDate->copy($oStatsStartDate);
$oEndDate = new Date();
}
// Prepare the return array
$aDatesResult = array();
switch ($breakdown) {
case 'week':
case 'day':
$oOneDaySpan = new Date_Span('1', '%d');
$oEndDate->addSpan($oOneDaySpan);
$oDate = new Date();
$oDate->copy($oStartDate);
while ($oDate->before($oEndDate)) {
$aDatesResult[$oDate->format('%Y-%m-%d')] = $oDate->format($GLOBALS['date_format']);
$oDate->addSpan($oOneDaySpan);
}
break;
case 'month':
$oOneMonthSpan = new Date_Span((string) ($oEndDate->getDaysInMonth() - $oEndDate->getDay() + 1), '%d');
$oEndDate->addSpan($oOneMonthSpan);
$oDate = new Date();
$oDate->copy($oStartDate);
while ($oDate->before($oEndDate)) {
$aDatesResult[$oDate->format('%Y-%m')] = $oDate->format($GLOBALS['month_format']);
$oOneMonthSpan = new Date_Span((string) ($oDate->getDaysInMonth() - $oDate->getDay() + 1), '%d');
$oDate->addSpan($oOneMonthSpan);
}
break;
case 'dow':
for ($dow = 0; $dow < 7; $dow++) {
$aDatesResult[$dow] = $GLOBALS['strDayFullNames'][$dow];
}
break;
case 'hour':
for ($hour = 0; $hour < 24; $hour++) {
$aDatesResult[$hour] = sprintf('%02d:00 - %02d:59', $hour, $hour);
}
break;
}
return $aDatesResult;
}
示例6: switch
/**
* A private method that returns the start and end dates
* that bound the span, based based on a pre-defined 'friendly'
* value.
*
* See the {@link OA_Admin_DaySpan::setSpanPresetValue()} method
* for the pre-defined values.
*
* @param string $presetValue The preset value string.
* @return array An array of two elements, "start" and "end",
* representing the start and end dates of
* the span, respectively.
*/
function _getSpanDates($presetValue)
{
switch ($presetValue) {
case 'today':
$oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
$oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
break;
case 'yesterday':
$oDateStart = new Date(Date_Calc::prevDay($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
$oDateEnd = new Date(Date_Calc::prevDay($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
break;
case 'this_week':
$oDateStart = new Date(Date_Calc::beginOfWeek($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
$oSixDaySpan = new Date_Span();
$oSixDaySpan->setFromDays(6);
$oSevenDaySpan = new Date_Span();
$oSevenDaySpan->setFromDays(7);
// Now have week start and end when week starts on Sunday
// Does the user want to start on a different day?
$beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek();
if ($beginOfWeek > 0) {
$oRequiredDaysSpan = new Date_Span();
$oRequiredDaysSpan->setFromDays($beginOfWeek);
$oDateStart->addSpan($oRequiredDaysSpan);
$oDateToday = new Date($this->oNowDate->format('%Y-%m-%d'));
if ($oDateToday->getDayOfWeek() < $beginOfWeek) {
$oDateStart->subtractSpan($oSevenDaySpan);
}
}
$oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
break;
case 'last_week':
$oDateStart = new Date(Date_Calc::beginOfPrevWeek($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
$oSixDaySpan = new Date_Span();
$oSixDaySpan->setFromDays(6);
$oSevenDaySpan = new Date_Span();
$oSevenDaySpan->setFromDays(7);
// Now have week start and end when week starts on Sunday
// Does the user want to start on a different day?
$beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek();
if ($beginOfWeek > 0) {
$oRequiredDaysSpan = new Date_Span();
$oRequiredDaysSpan->setFromDays($beginOfWeek);
$oDateStart->addSpan($oRequiredDaysSpan);
$oDateToday = new Date($this->oNowDate->format('%Y-%m-%d'));
if ($oDateToday->getDayOfWeek() < $beginOfWeek) {
$oDateStart->subtractSpan($oSevenDaySpan);
}
}
$oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
$oDateEnd->copy($oDateStart);
$oDateEnd->addSpan($oSixDaySpan);
break;
case 'last_7_days':
$oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
$oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
$oOneDaySpan = new Date_Span();
$oOneDaySpan->setFromDays(1);
$oSevenDaySpan = new Date_Span();
$oSevenDaySpan->setFromDays(7);
$oDateStart->subtractSpan($oSevenDaySpan);
$oDateEnd->subtractSpan($oOneDaySpan);
break;
case 'this_month':
$oDateStart = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
$oDateEnd = new Date($this->oNowDate->format('%Y-%m-%d'));
break;
case 'this_month_full':
$oDateStart = new Date(Date_Calc::beginOfMonth($this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
$oDateEnd = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
$oOneDaySpan = new Date_Span();
$oOneDaySpan->setFromDays(1);
$oDateEnd->subtractSpan($oOneDaySpan);
break;
case 'this_month_remainder':
$oDateStart = new Date($this->oNowDate->format('%Y-%m-%d'));
$oDateEnd = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
$oOneDaySpan = new Date_Span();
$oOneDaySpan->setFromDays(1);
$oDateEnd->subtractSpan($oOneDaySpan);
break;
case 'next_month':
$oDateStart = new Date(Date_Calc::beginOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
$oDateEnd = new Date(Date_Calc::endOfNextMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
break;
case 'last_month':
$oDateStart = new Date(Date_Calc::beginOfPrevMonth($this->oNowDate->format('%d'), $this->oNowDate->format('%m'), $this->oNowDate->format('%Y')));
//.........这里部分代码省略.........
示例7: Date
/**
* A private method to caclucate the number of days left until a
* campaign expires based on the impression, click or conversion
* delivery targets & the delivery rate of the campaign to date.
*
* @param array $aDeliveryData An array of two items. "delivered":
* the number of impressions, clicks or
* conversions delivered so far; and
* "day_of_first": a string in YYYY-MM-DD
* format representing the day that the
* first impression, click or conversion
* was delivered.
* @param integer $target The total number of impressions, clicks
* or conversions required to be delivered
* by the campaign.
* @return array An array of three items. "daysLeft": the estimated
* number of days remaining until the campaign ends;
* "date": the estimated date of expiration; and "date_f"
*/
function _calculateRemainingDays($aDeliveryData, $target)
{
global $date_format;
$oNowDate = new Date();
$aExpiration = array();
// How many days since the first impression/click/conversion?
if (!empty($aDeliveryData['day_of_first'])) {
$oFirstDate = new Date($aDeliveryData['day_of_first']);
$oSpan = new Date_Span();
$oSpan->setFromDateDiff($oFirstDate, $oNowDate);
$daysSinceFirst = ceil($oSpan->toDays());
} else {
$daysSinceFirst = 1;
}
// Have *any* impressions/clicks/conversions been delivered?
if (!empty($aDeliveryData["delivered"]) && $aDeliveryData["delivered"] > 0) {
$targetRemaining = $target - $aDeliveryData["delivered"];
$deliveryRate = $aDeliveryData["delivered"] / $daysSinceFirst;
$daysLeft = (int) round($targetRemaining / $deliveryRate);
$oSpan = new Date_Span();
$oSpan->setFromDays($daysLeft);
$oEstimatedEndDate = new Date();
$oEstimatedEndDate->addSpan($oSpan);
if ($oEstimatedEndDate->before($oNowDate)) {
// Ooop! Wrapped into the past - get the biggest possible date
$oEstimatedEndDate = new Date('1960-01-01 00:00:00');
$oEstimatedEndDate->subtractSeconds(1);
}
$estimatedEndDateFormat = $oEstimatedEndDate->format($date_format);
$aExpiration = array('daysLeft' => $daysLeft, 'date_f' => $estimatedEndDateFormat, 'date' => $oEstimatedEndDate);
}
return $aExpiration;
}
示例8: Date
/**
* A method to generate data for testing.
*
* @access private
*/
function _generateStatsOne()
{
$oDate = new Date();
$oDate->setHour(23);
$oDate->setMinute(59);
$oDate->setSecond(59);
$oDate->addSpan(new Date_Span('4-0-0-0'));
$expiryDate1 = $oDate->getDate(DATE_FORMAT_ISO);
$oDate->addSpan(new Date_Span('4-0-0-0'));
$expiryDate2 = $oDate->getDate(DATE_FORMAT_ISO);
$oDate->subtractSpan(new Date_Span('2-0-0-0'));
$expiryDateLessTwoDays = $oDate->getDate(DATE_FORMAT_ISO);
$doAcls = OA_Dal::factoryDO('acls');
$doBanners = OA_Dal::factoryDO('banners');
// default values
$doBanners->status = OA_ENTITY_STATUS_RUNNING;
$doBanners->contenttype = 'gif';
$doBanners->pluginversion = 0;
$doBanners->storagetype = 'sql';
$doBanners->filename = '468x60_4.gif';
$doBanners->imageurl = '';
$doBanners->htmltemplate = '';
$doBanners->htmlcache = '';
$doBanners->width = 468;
$doBanners->height = 60;
$doBanners->weight = 1;
$doBanners->seq = 0;
$doBanners->target = '';
$doBanners->url = 'http://www.example.com';
$doBanners->alt = 'Campaign Alt Text';
$doBanners->statustext = '';
$doBanners->bannertext = '';
$doBanners->description = '';
$doBanners->adserver = '';
$doBanners->block = 0;
$doBanners->capping = 0;
$doBanners->session_capping = 0;
$doBanners->compiledlimitation = '';
$doBanners->prepend = '';
$doBanners->append = '';
$doBanners->bannertype = 0;
$doBanners->alt_filename = '';
$doBanners->alt_imageurl = '';
$doBanners->alt_contenttype = '';
$clientId = DataGenerator::generateOne('clients', true);
// Add 3 campaigns - haha!
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Test Campaign 1';
$doCampaigns->clientid = $clientId;
$doCampaigns->views = 0;
$doCampaigns->clicks = 400;
$doCampaigns->conversions = 0;
$doCampaigns->expire_time = $expiryDate1;
$doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
$doCampaigns->priority = '3';
$doCampaigns->weight = 1;
$doCampaigns->target_impression = 0;
$doCampaigns->anonymous = 'f';
$doCampaigns->updated = $oDate->format('%Y-%m-%d %H:%M:%S');
$idCampaign1 = DataGenerator::generateOne($doCampaigns, true);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Test Campaign 2';
$doCampaigns->clientid = $clientId;
$doCampaigns->views = 0;
$doCampaigns->clicks = 0;
$doCampaigns->conversions = 400;
$doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
$doCampaigns->priority = '2';
$doCampaigns->weight = 1;
$doCampaigns->target_impression = 0;
$doCampaigns->anonymous = 'f';
$doCampaigns->updated = $oDate->format('%Y-%m-%d %H:%M:%S');
$idCampaign2 = DataGenerator::generateOne($doCampaigns, true);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Test Campaign 3';
$doCampaigns->clientid = $clientId;
$doCampaigns->views = 500;
$doCampaigns->clicks = 0;
$doCampaigns->conversions = 0;
$doCampaigns->expire = $expiryDate2;
$doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
$doCampaigns->priority = '3';
$doCampaigns->weight = 1;
$doCampaigns->target_impression = 0;
$doCampaigns->anonymous = 'f';
$doCampaigns->updated = $oDate->format('%Y-%m-%d %H:%M:%S');
$idCampaign3 = DataGenerator::generateOne($doCampaigns, true);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Test Campaign 4';
$doCampaigns->clientid = $clientId;
$doCampaigns->views = 500;
$doCampaigns->clicks = 0;
$doCampaigns->conversions = 401;
$doCampaigns->status = OA_ENTITY_STATUS_RUNNING;
$doCampaigns->priority = '4';
//.........这里部分代码省略.........
示例9: Date
/**
* Build the internal arrays that contain data about the calculated holidays
*
* @access protected
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
*/
function _buildHolidays()
{
parent::_buildHolidays();
$easterDate = $this->getHolidayDate('easter');
$ashWednesdayDate = $this->getHolidayDate('ashWednesday');
$ascensionDayDate = $this->getHolidayDate('ascensionDay');
$advent1Date = $this->getHolidayDate('advent1');
/**
* New Year's Day
*/
$this->_addHoliday('newYearsDay', $this->_year . '-01-01', 'New Year\'s Day');
/**
* Valentine's Day
*/
$this->_addHoliday('valentinesDay', $this->_year . '-02-14', 'Valentine\'s Day');
/**
* "Weiberfastnacht"
*/
$wFasnetDate = new Date($ashWednesdayDate);
$wFasnetDate->subtractSpan(new Date_Span('6, 0, 0, 0'));
$this->_addHoliday('womenFasnet', $wFasnetDate, 'Carnival');
/**
* Carnival / "Fastnacht"
*/
$fasnetDate = new Date($easterDate);
$fasnetDate->subtractSpan(new Date_Span('47, 0, 0, 0'));
$this->_addHoliday('fasnet', $fasnetDate, 'Carnival');
/**
* Rose Monday
*/
$roseMondayDate = new Date($easterDate);
$roseMondayDate->subtractSpan(new Date_Span('48, 0, 0, 0'));
$this->_addHoliday('roseMonday', $roseMondayDate, 'Rose Monday');
/**
* International Women's Day
*/
$this->_addHoliday('womensDay', $this->_year . '-03-08', 'International Women\'s Day');
/**
* April 1st
*/
$this->_addHoliday('april1st', $this->_year . '-04-01', 'April 1st');
/**
* Girls' Day (fourth Thursday in April)
*/
$girlsDayDate = new Date($this->_year . '-04-01');
$dayOfWeek = $girlsDayDate->getDayOfWeek();
switch ($dayOfWeek) {
case 0:
case 1:
case 2:
case 3:
$span = new Date_Span(sprintf('%d, 0, 0, 0', 4 - $dayOfWeek + 21));
break;
case 4:
$span = new Date_Span('21, 0, 0, 0');
break;
case 5:
case 6:
$span = new Date_Span(sprintf('%d, 0, 0, 0', -1 * $dayOfWeek + 11 + 21));
break;
}
$girlsDayDate->addSpan($span);
$this->_addHoliday('girlsDay', $girlsDayDate, 'Girls\' Day');
/**
* International Earth' Day
*/
$this->_addHoliday('earthDay', $this->_year . '-04-22', 'International Earth\' Day');
/**
* German Beer's Day
*/
$this->_addHoliday('beersDay', $this->_year . '-04-23', 'German Beer\'s Day');
/**
* Walpurgis Night
*/
$this->_addHoliday('walpurgisNight', $this->_year . '-04-30', 'Walpurgis Night');
/**
* Day of Work
*/
$this->_addHoliday('dayOfWork', $this->_year . '-05-01', 'Day of Work');
/**
* World's Laughing Day
*/
$laughingDayDate = new Date($this->_year . '-05-01');
while ($laughingDayDate->getDayOfWeek() != 0) {
$laughingDayDate = $laughingDayDate->getNextDay();
}
$this->_addHoliday('laughingDay', $laughingDayDate, 'World\'s Laughing Day');
/**
* Europe Day
*/
$this->_addHoliday('europeDay', $this->_year . '-05-05', 'Europe Day');
/**
* Mothers' Day
//.........这里部分代码省略.........
示例10: Date
function test_getAuditLogForAuditWidget()
{
$dllAuditPartialMock = new PartialMockOA_Dll_Audit($this);
$oSpanDay = new Date_Span('1-0-0-0');
$oDate = new Date(OA::getNow());
$oDate->toUTC();
$oDate->subtractSpan(new Date_Span('8-0-0-0'));
// add 1 hour to make sure that the test passes even if it takes some time
$oDate->addSpan(new Date_Span('0-1-0-0'));
// record 1 - more than 7 days old so should not be returned
$oAudit = OA_Dal::factoryDO('audit');
$oAudit->account_id = 1;
$oAudit->context = 'campaigns';
$oAudit->contextid = 1;
$oAudit->parentid = null;
$oAudit->username = 'user1';
$oAudit->actionid = OA_AUDIT_ACTION_UPDATE;
$oAudit->updated = $oDate->getDate();
$aDetails['campaignname'] = 'Campaign 1';
$aDetails['status'] = OA_ENTITY_STATUS_EXPIRED;
$oAudit->details = serialize($aDetails);
$oAudit->insert();
// record 2
$oDate->addSpan($oSpanDay);
$oAudit->updated = $oDate->getDate();
$oAudit->username = 'user2';
$aDetails['status'] = OA_ENTITY_STATUS_RUNNING;
$oAudit->details = serialize($aDetails);
$idAudit = $oAudit->insert();
$aExpect[$idAudit] = $oAudit->toArray();
$aExpect[$idAudit]['details'] = $aDetails;
// record 3
$oDate->addSpan($oSpanDay);
$oAudit->updated = $oDate->getDate();
$oAudit->username = 'user3';
$aDetails['status'] = OA_ENTITY_STATUS_PAUSED;
$oAudit->details = serialize($aDetails);
$idAudit = $oAudit->insert();
$aExpect[$idAudit] = $oAudit->toArray();
$aExpect[$idAudit]['details'] = $aDetails;
// record 4
$oDate->addSpan($oSpanDay);
$oAudit->contextid = 2;
$oAudit->updated = $oDate->getDate();
$aDetails['campaignname'] = 'Campaign 2';
$aDetails['status'] = OA_ENTITY_STATUS_RUNNING;
$oAudit->details = serialize($aDetails);
$idAudit = $oAudit->insert();
$aExpect[$idAudit] = $oAudit->toArray();
$aExpect[$idAudit]['details'] = $aDetails;
// record 5
$oDate->addSpan($oSpanDay);
$oAudit->updated = $oDate->getDate();
$oAudit->username = 'user2';
$aDetails['status'] = OA_ENTITY_STATUS_EXPIRED;
$oAudit->details = serialize($aDetails);
$idAudit = $oAudit->insert();
$aExpect[$idAudit] = $oAudit->toArray();
$aExpect[$idAudit]['details'] = $aDetails;
// record 6
$oDate->addSpan($oSpanDay);
$oAudit->account_id = 2;
$oAudit->contextid = 3;
$oAudit->username = 'user1';
$oAudit->updated = $oDate->getDate();
$aDetails['campaignname'] = 'Campaign 3';
$aDetails['status'] = OA_ENTITY_STATUS_RUNNING;
$oAudit->details = serialize($aDetails);
$idAudit = $oAudit->insert();
$aExpect[$idAudit] = $oAudit->toArray();
$aExpect[$idAudit]['details'] = $aDetails;
// record 7 - is a maintenance audit rec so should not be returned
$oDate->addSpan($oSpanDay);
$oAudit->username = 'Maintenance';
$oAudit->contextid = 1;
$oAudit->updated = $oDate->getDate();
$aDetails['campaignname'] = 'Campaign 1';
$aDetails['status'] = OA_ENTITY_STATUS_RUNNING;
$oAudit->details = serialize($aDetails);
$oAudit->insert();
$aParams = array();
$aResults = $dllAuditPartialMock->getAuditLogForAuditWidget($aParams);
$this->assertIsA($aResults, 'array');
$this->assertEqual(count($aResults), 5);
foreach ($aResults as $i => $aResRow) {
$aExpRow = $aExpect[$aResRow['auditid']];
$this->assertEqual($aResRow['auditid'], $aExpRow['auditid']);
$this->assertEqual($aResRow['actionid'], $aExpRow['actionid']);
$this->assertEqual($aResRow['context'], $dllAuditPartialMock->getContextDescription($aExpRow['context']));
$this->assertEqual($aResRow['contextid'], $aExpRow['contextid']);
$this->assertEqual($aResRow['parentid'], $aExpRow['parentid']);
$this->assertEqual($aResRow['username'], $aExpRow['username']);
$this->assertEqual($aResRow['details']['campaignname'], $aExpRow['details']['campaignname']);
$this->assertEqual($aResRow['details']['status'], $aExpRow['details']['status']);
$oDate = new Date($aResRow['updated']);
$oDate->toUTC();
$this->assertEqual($oDate->getDate(), $aExpRow['updated']);
}
// Check that the account_id filter is working
$aParams = array('account_id' => 2);
//.........这里部分代码省略.........
示例11: getAuditLog
/**
* Gets a log of audit events
*
* @param array $aParam An optional associative array containing various parameters to
* filter the audit trail results. Possible keys / values are:
*
* - account_id Filter the results by manager account ID.
* - advertiser_account_id Filter the results by advertiser account ID.
* - website_account_id Filter the results by website account ID.
*
* - start_date & end_date Only display results between dates, in
* "YYYY-MM-DD" string formats.
*
* - advertiser_id Filter the results by advertiser ID.
* - campaign_id Also filter the results by campaign ID;
* requires advertiser_id to be set.
*
* - publisher_id Filter the results by publisher ID.
* - zone_id Also filter the results by zone ID;
* requires publisher_id to be set.
*
* NOTE: The advertiser and publisher filtering types cannot be
* combined, if they are, the advertiser filters will
* be used.
*
*
*
* - order Set to "down" to have in descending order.
* - listorder The audit trail column to order by.
*
* - startRecord Record to begin paging?
* - perPage Number of items displayed per page?
*
* @return array An associative array containing the audit events for the specified parameters
*/
function getAuditLog($aParam = null)
{
// Prepare the audit trail table DB_DataObject
$doAudit = OA_Dal::factoryDO('audit');
// Are there any parameters?
if (!empty($aParam) && is_array($aParam)) {
// Check for, and apply, as required, any filters to ensure
// that the results displayed are those that the current
// account has access to
if (!empty($aParam['account_id'])) {
$where = "account_id = {}";
$doAudit->account_id = $aParam['account_id'];
}
if (!empty($aParam['advertiser_account_id'])) {
$doAudit->advertiser_account_id = $aParam['advertiser_account_id'];
}
if (!empty($aParam['website_account_id'])) {
$doAudit->website_account_id = $aParam['website_account_id'];
}
// Check for, and apply, as required, any filters to ensure
// that the results displayed are those in the desired date range
if (!empty($aParam['start_date']) && !empty($aParam['end_date'])) {
$oStartDate = new Date($aParam['start_date']);
$oStartDate->toUTC();
$oEndDate = new Date($aParam['end_date']);
$oEndDate->addSpan(new Date_Span('1-0-0-0'));
$oEndDate->toUTC();
$doAudit->whereAdd('updated >= ' . DBC::makeLiteral($oStartDate->format('%Y-%m-%d %H:%M:%S')));
$doAudit->whereAdd('updated < ' . DBC::makeLiteral($oEndDate->format('%Y-%m-%d %H:%M:%S')));
}
// Check for, and apply, as required, any filters to ensure
// that the results displayed are those in the desired advertiser ID;
// OR, check for, and apply, as required, and filters to ensure
// that the results displayed are those in the desired publisher ID.
if (!empty($aParam['advertiser_id']) && is_numeric($aParam['advertiser_id']) && $aParam['advertiser_id'] > 0) {
$aWhere = array();
$campaignIdSet = true;
// Also check for, and apply, as required and filters to
// ensure that the results displayed are ALSO for the
// desired campaign ID
if (empty($aParam['campaign_id']) || !is_numeric($aParam['campaign_id']) || $aParam['campaign_id'] <= 0) {
// The campaign ID is not set, so filtering by advertiser ID only
// - Unset the fact that the campaign ID is set; and
// - Add the where clause to include advertiser ID level events
$campaignIdSet = false;
$aWhere[] = "(context = 'clients' AND contextid = " . $doAudit->quote($aParam['advertiser_id']) . ")";
}
// Add the where clause to include campaign level events
$aCampaignIds = array();
// Find all campaigns in the advertiser
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->clientid = $aParam['advertiser_id'];
if ($campaignIdSet) {
// Also limit to the set campaign ID
$doCampaigns->campaignid = $aParam['campaign_id'];
}
$doCampaigns->find();
if ($doCampaigns->getRowCount() > 0) {
while ($doCampaigns->fetch()) {
// Add the campaign ID to the list of campaigns in the advertiser
$aCampaignIds[] = $doAudit->quote($doCampaigns->campaignid);
}
}
if (!empty($aCampaignIds)) {
$aWhere[] = "(context = 'campaigns' AND contextid IN (" . implode(',', $aCampaignIds) . "))";
//.........这里部分代码省略.........
示例12: Date
/**
* Build the internal arrays that contain data about the calculated holidays
*
* @access protected
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
*/
function _buildHolidays()
{
/**
* Circumcision of Jesus
*/
$this->_addHoliday('jesusCircumcision', $this->_year . '-01-01', 'Circumcision of Jesus');
/**
* Epiphanias
*/
$this->_addHoliday('epiphany', $this->_year . '-01-06', 'Epiphany');
/**
* Cleaning of Mariä
*/
$this->_addHoliday('mariaCleaning', $this->_year . '-02-02', 'Cleaning of Maria');
/**
* Josef's Day
*/
$this->_addHoliday('josefsDay', $this->_year . '-03-19', 'Josef\'s Day');
/**
* Maria Announcement
*/
$this->_addHoliday('mariaAnnouncement', $this->_year . '-03-25', 'Maria Announcement');
/**
* Easter Sunday
*/
$easterDate = Date_Holidays_Driver_Christian::calcEaster($this->_year);
$this->_addHoliday('easter', $easterDate, 'Easter Sunday');
/**
* Palm Sunday
*/
$palmSundayDate = new Date($easterDate);
$palmSundayDate->subtractSpan(new Date_Span('7, 0, 0, 0'));
$this->_addHoliday('palmSunday', $palmSundayDate, 'Palm Sunday');
/**
* Passion Sunday
*/
$passionSundayDate = new Date($palmSundayDate);
$passionSundayDate->subtractSpan(new Date_Span('7, 0, 0, 0'));
$this->_addHoliday('passionSunday', $passionSundayDate, 'Passion Sunday');
/**
* Painful Friday
*/
$painfulFridayDate = new Date($palmSundayDate);
$painfulFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'));
$this->_addHoliday('painfulFriday', $painfulFridayDate, 'Painful Friday');
/**
* White Sunday
*/
$whiteSundayDate = new Date($easterDate);
$whiteSundayDate->addSpan(new Date_Span('7, 0, 0, 0'));
$this->_addHoliday('whiteSunday', $whiteSundayDate, 'White Sunday');
/**
* Ash Wednesday
*/
$ashWednesdayDate = new Date($easterDate);
$ashWednesdayDate->subtractSpan(new Date_Span('46, 0, 0, 0'));
$this->_addHoliday('ashWednesday', $ashWednesdayDate, 'Ash Wednesday');
/**
* Good Friday / Black Friday
*/
$goodFridayDate = new Date($easterDate);
$goodFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'));
$this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
/**
* Green Thursday
*/
$this->_addHoliday('greenThursday', $goodFridayDate->getPrevDay(), 'Green Thursday');
/**
* Easter Monday
*/
$this->_addHoliday('easterMonday', $easterDate->getNextDay(), 'Easter Monday');
/**
* Whitsun (determines Whit Monday, Ascension Day and Feast of Corpus Christi)
*/
$whitsunDate = new Date($easterDate);
$whitsunDate->addSpan(new Date_Span('49, 0, 0, 0'));
$this->_addHoliday('whitsun', $whitsunDate, 'Whitsun');
/**
* Request Sunday
*/
$requestSunday = new Date($whitsunDate);
$requestSunday->subtractSpan(new Date_Span('14, 0, 0, 0'));
$this->_addHoliday('requestSunday', $requestSunday, 'Request Sunday');
/**
* Ascension Day
*/
$ascensionDayDate = new Date($whitsunDate);
$ascensionDayDate->subtractSpan(new Date_Span('10, 0, 0, 0'));
$this->_addHoliday('ascensionDay', $ascensionDayDate, 'Ascension Day');
/**
* Whit Monday
*/
$this->_addHoliday('whitMonday', $whitsunDate->getNextDay(), 'Whit Monday');
//.........这里部分代码省略.........
示例13: Date
/**
* Build the internal arrays that contain data about the calculated holidays
*
* @access protected
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
*/
function _buildHolidays()
{
/**
* New Year's Day
*/
$this->_addHoliday('newYearsDay', $this->_year . '-01-01', 'New Year\'s Day');
/**
* Easter Sunday
*/
$easterDate = Date_Holidays_Driver_Norway::calcEaster($this->_year);
$this->_addHoliday('easter', $easterDate, 'Easter Sunday');
/**
* Good Friday / Black Friday
*/
$goodFridayDate = new Date($easterDate);
$goodFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'));
$this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
/**
* Easter Monday
*/
$this->_addHoliday('easterMonday', $easterDate->getNextDay(), 'Easter Monday');
/**
* May Day
*/
$this->_addHoliday('mayDay', $this->_year . '-05-01', 'May Day');
/**
* Pentecost (determines Whit Monday, Ascension Day and Feast of Corpus Christi)
*/
$pentecostDate = new Date($easterDate);
$pentecostDate->addSpan(new Date_Span('49, 0, 0, 0'));
$this->_addHoliday('pentecost', $pentecostDate, 'Pentecost');
/**
* Ascension Day
*/
$ascensionDayDate = new Date($pentecostDate);
$ascensionDayDate->subtractSpan(new Date_Span('10, 0, 0, 0'));
$this->_addHoliday('ascensionDay', $ascensionDayDate, 'Ascension Day');
/**
* Norwegian National Day
*/
$this->_addHoliday('norwayNationalDay', $this->_year . '-05-17', 'Norwegian National Day');
/**
* Christmas Eve
*/
$this->_addHoliday('xmasEve', $this->_year . '-12-24', 'Christmas Eve');
/**
* Christmas day
*/
$this->_addHoliday('xmasDay', $this->_year . '-12-25', 'Christmas Day');
/**
* Boxing day
*/
$this->_addHoliday('boxingDay', $this->_year . '-12-26', 'Boxing Day');
/**
* New Year's Eve
*/
$this->_addHoliday('newYearsEve', $this->_year . '-12-31', 'New Year\'s Eve');
if (Date_Holidays::errorsOccurred()) {
return Date_Holidays::getErrorStack();
}
return true;
}
示例14: array
/**
* A method to test the sending of emails from the
* manageCampaigns() method - tests the sending of
* the "campaign deactivated" emails.
*/
function testManageCampaignsEmailsPlacementDeactivated()
{
// Prepare a single placement that is active, and has a lifetime
// impression target that has been met (so that it will need to
// be deactivated)
$aData = array('contact' => 'Test Placement Deactivated Contact', 'email' => 'postmaster@placement.deactivated', 'reportdeactivate' => 't', 'report' => 't');
$advertiserId = $this->_insertAdvertiser($aData);
$aAdvertiser = OA_DAL::staticGetDO('clients', $advertiserId)->toArray();
$aData = array('status' => OA_ENTITY_STATUS_RUNNING, 'views' => '100');
$campaignId = $this->_insertPlacement($aData);
$aData = array('campaignid' => $campaignId);
$adId = $this->_insertAd($aData);
$aData = array('operation_interval_id' => 25, 'interval_start' => '2005-12-08 00:00:00', 'interval_end' => '2004-12-08 00:59:59', 'hour' => 0, 'ad_id' => 1, 'impressions' => 101);
$this->_insertDataIntermediateAd($aData);
// Create an instance of the mocked OA_Email class, and set
// expectations on how the class' methods should be called
// based on the above
Mock::generate('OA_Email');
$oEmailMock = new MockOA_Email($this);
$oEmailMock->expectOnce('sendCampaignActivatedDeactivatedEmail', array("{$campaignId}", 2));
// This is the date that is going to be used later
$oDate = new Date();
$oEnd = new Date($oDate);
$oEnd->addSpan(new Date_Span('1-0-0-0'));
$oEmailMock->expectOnce('sendCampaignDeliveryEmail', array($aAdvertiser, new Date($aAdvertiser['reportlastdate']), $oEnd, "{$campaignId}"));
// Register the mocked OA_Email class in the service locator
$oServiceLocator =& OA_ServiceLocator::instance();
$oServiceLocator->register('OA_Email', $oEmailMock);
// Run the manageCampaigns() method and ensure that the correct
// calls to OA_Email were made
$oFactory = new OX_Dal_Maintenance_Statistics_Factory();
$oDalMaintenanceStatistics = $oFactory->factory();
$report = $oDalMaintenanceStatistics->manageCampaigns($oDate);
$oEmailMock->tally();
// Clean up
DataGenerator::cleanUp();
}
示例15: getExpirationDate
public function getExpirationDate() {
$startDate = new Date(isset($this->m_data['StartDate']) ? $this->m_data['StartDate'] : 0);
$timeSpan = new Date_Span();
$timeSpan->setFromDays($this->m_data['Days']);
$startDate->addSpan($timeSpan);
return $startDate->getDate();
}