本文整理汇总了PHP中Date::getDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::getDate方法的具体用法?PHP Date::getDate怎么用?PHP Date::getDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::getDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startUserSession
public function startUserSession($row)
{
$login_key = $_SESSION['login_key'];
# Unset all session variable
$_SESSION = array();
# Destroy session
session_destroy();
# New session name
session_name(SESS_NAME);
# New session id
session_id($login_key);
# Start Session
session_start();
$ts = new Date();
# Initialize session
$_SESSION['start_ts'] = $ts->getTs();
$_SESSION['start_ts_str'] = $ts->getDate();
$_SESSION['auth_state'] = 'user';
$_SESSION['user_id'] = $row['id'];
$_SESSION['login_key'] = $login_key;
# Destroy old User object
$this->user->__destruct();
# Initialize new User object
$this->user = User::getInstance($_SESSION['user_id']);
}
示例2: sendSqlDump
function sendSqlDump()
{
$result = BADGER_VERSION_TAG . "\n";
$result .= getDbDump();
$now = new Date();
header('Content-Type: text/sql');
header('Content-Disposition: attachment; filename="BADGER-' . getBadgerDbVersion() . '-DatabaseBackup-' . $now->getDate() . '.sql"');
header('Content-Length: ' . strlen($result));
echo $result;
}
示例3: getTime
function getTime($format)
{
// reuse Date - pretty much does the same thing
// I would have just deleted this class altogether
// and just used the Date Model but the instructions said
// each page should have it's own class - not knowing
// completely what they meant, I just decided to
// do it this way. Hopefully it's not a ding in
// judgement. Adam
return Date::getDate($format);
}
示例4: takeAction
/**
* Performs the action; returns true on success, false on error.
*
* @param $p_context - the current context object
* @return bool
*/
public function takeAction(CampContext &$p_context)
{
$p_context->default_url->reset_parameter('f_' . $this->m_name);
$p_context->url->reset_parameter('f_' . $this->m_name);
if (PEAR::isError($this->m_error)) {
return false;
}
$auth = Zend_Auth::getInstance();
$user = new User($p_context->user->identifier);
if ($user->getUserId() != $auth->getIdentity() || $user->getUserId() == 0) {
$this->m_error = new PEAR_Error('You must be logged in to create or edit your subscription.', ACTION_EDIT_SUBSCRIPTION_ERR_NO_USER);
return false;
}
$subscriptions = Subscription::GetSubscriptions($p_context->publication->identifier, $user->getUserId());
if (count($subscriptions) == 0) {
$subscription = new Subscription();
$created = $subscription->create(array('IdUser' => $user->getUserId(), 'IdPublication' => $p_context->publication->identifier, 'Active' => 'Y', 'Type' => $this->m_subscriptionType == 'trial' ? 'T' : 'P'));
if (!$created) {
$this->m_error = new PEAR_Error('Internal error (code 1)', ACTION_EDIT_SUBSCRIPTION_ERR_INTERNAL);
exit(1);
}
} else {
$subscription = $subscriptions[0];
}
$publication = new Publication($p_context->publication->identifier);
$subscriptionDays = $this->computeSubscriptionDays($publication, $p_context->publication->subscription_time);
$startDate = new Date();
$columns = array('StartDate' => $startDate->getDate(), 'Days' => $subscriptionDays, 'PaidDays' => $this->m_subscriptionType == 'trial' ? $subscriptionDays : 0, 'NoticeSent' => 'N');
if ($this->m_properties['subs_by_type'] == 'publication') {
$sectionsList = Section::GetUniqueSections($p_context->publication->identifier);
foreach ($sectionsList as $section) {
$this->m_sections[] = $section['id'];
}
}
foreach ($this->m_languages as $languageId) {
foreach ($this->m_sections as $sectionNumber) {
$subsSection = new SubscriptionSection($subscription->getSubscriptionId(), $sectionNumber, $languageId);
$subsSection->create($columns);
}
}
$fields = array('SubsType', 'tx_subs', 'nos', 'unitcost', 'unitcostalllang', 'f_substype', 'cb_subs', 'subs_all_languages', 'suma', 'tpl', 'subscription_language');
foreach (CampRequest::GetInput() as $field => $value) {
if (strncmp('tx_subs', $field, strlen('tx_subs')) == 0) {
$fields[] = $field;
}
}
foreach ($fields as $fieldName) {
$p_context->default_url->reset_parameter($fieldName);
$p_context->url->reset_parameter($fieldName);
}
$this->m_error = ACTION_OK;
return true;
}
示例5: Date
/**
* A method that uses the getAllCampaigns() method to obtain all campaigns
* that meet the requirements of this class. That is:
*
* - The campaign has an expiration date (that is not already passed); and
* - As a result of the above, the campaign must have an activation date that has
* passed, or has the default fake activation date; and
* - The campaign is active, and has a priority of at least 1; and
* - The campaign has inventory requirements for the duration of its activation.
*
* @access private
* @return array An array of {@link OX_Maintenance_Priority_Campaign} objects.
*/
function _getValidCampaigns()
{
$conf = $GLOBALS['_MAX']['CONF'];
// Get current date
$oDate = new Date($this->_getDate());
$oDate->toUTC();
$dateYMD = $oDate->getDate(DATE_FORMAT_ISO);
$oDbh = OA_DB::singleton();
$table = $oDbh->quoteIdentifier($conf['table']['prefix'] . $conf['table']['campaigns'], true);
$aWheres = array(array("{$table}.priority >= 1", 'AND'), array("{$table}.status = " . OA_ENTITY_STATUS_RUNNING, 'AND'), array("{$table}.expire_time >= '{$dateYMD}'", 'AND'), array("({$table}.views > 0 OR {$table}.clicks > 0 OR {$table}.conversions > 0)", 'AND'));
return $this->_getAllCampaigns($aWheres);
}
示例6: setVariables
/**
* A helper method to set applicationvariables
*
* @param Date $oScheduledDate
* @param Date $oDate
*/
function setVariables($oScheduledDate, $oDate)
{
if (isset($oScheduledDate)) {
OA_Dal_ApplicationVariables::set('maintenance_cron_timestamp', $oScheduledDate->getDate(DATE_FORMAT_UNIXTIME));
} else {
OA_Dal_ApplicationVariables::delete('maintenance_cron_timestamp');
}
if (isset($oDate)) {
OA_Dal_ApplicationVariables::set('maintenance_timestamp', $oDate->getDate(DATE_FORMAT_UNIXTIME));
} else {
OA_Dal_ApplicationVariables::delete('maintenance_timestamp');
}
}
示例7: compare
public function compare(Date $date)
{
$currentTime = strtotime($this->getDate());
$argTime = strtotime($date->getDate());
if ($currentTime > $argTime) {
return 1;
//argumento menor
} elseif ($currentTime < $argTime) {
return -1;
//atual menor
}
return 0;
//iguais
}
示例8: getDailyAmount
/**
* Returns the Account balance for $account at the end of each day between $startDate and $endDate.
*
* Considers the planned transactions of $account.
*
* @param object $account The Account object for which the balance should be calculated.
* It should be 'fresh', i. e. no transactions of any type should have been fetched from it.
* @param object $startDate The first date the balance should be calculated for as Date object.
* @param object $endDate The last date the balance should be calculated for as Date object.
* @return array Array of Amount objects corresponding to the balance of $account at each day between
* $startDate and $endDate. The array keys are the dates as ISO-String (yyyy-mm-dd).
*/
function getDailyAmount($account, $startDate, $endDate)
{
$account->setTargetFutureCalcDate($endDate);
$account->setOrder(array(array('key' => 'valutaDate', 'dir' => 'asc')));
$result = array();
$startDate->setHour(0);
$startDate->setMinute(0);
$startDate->setSecond(0);
$endDate->setHour(0);
$endDate->setMinute(0);
$endDate->setSecond(0);
$currentDate = new Date($startDate);
$currentAmount = new Amount();
//foreach transaction
while ($currentTransaction = $account->getNextTransaction()) {
if ($currentDate->after($endDate)) {
//we reached $endDAte
break;
}
//fill all dates between last and this transaction with the old amount
while (is_null($tmp = $currentTransaction->getValutaDate()) ? false : $currentDate->before($tmp)) {
$result[$currentDate->getDate()] = new Amount($currentAmount);
$currentDate->addSeconds(24 * 60 * 60);
if ($currentDate->after($endDate)) {
//we reached $endDAte
break;
}
}
$currentAmount->add($currentTransaction->getAmount());
}
//fill all dates after the last transaction with the newest amount
while (Date::compare($currentDate, $endDate) <= 0) {
$result[$currentDate->getDate()] = new Amount($currentAmount);
$currentDate->addSeconds(24 * 60 * 60);
}
return $result;
}
示例9: ListAttributes2011
//.........这里部分代码省略.........
$checked = !empty($data[$attr["id"]]) ? 'checked="checked"' : '';
}
$output[$attr["id"]] .= sprintf("\n" . '<input type="checkbox" name="%s" value="on" %s class="input%s" />', $fieldname, $checked, $attr["required"] ? ' required' : '');
$output[$attr["id"]] .= sprintf("\n" . '<label for="%s" class="%s">%s</label>', $fieldname, $attr["required"] ? 'required' : '', stripslashes($attr["name"]));
break;
case "radio":
$output[$attr["id"]] .= sprintf("\n" . '<fieldset class="radiogroup %s"><legend>%s</legend>', $attr["required"] ? 'required' : '', stripslashes($attr["name"]));
$values_request = Sql_Query("select * from {$table_prefix}" . "listattr_" . $attr["tablename"] . " order by listorder,name");
while ($value = Sql_Fetch_array($values_request)) {
if (!empty($_POST[$fieldname])) {
$checked = $_POST[$fieldname] == $value["id"] ? 'checked="checked"' : '';
} else {
if ($data[$attr["id"]]) {
$checked = $data[$attr["id"]] == $value["id"] ? 'checked="checked"' : '';
} else {
$checked = $attr["default_value"] == $value["name"] ? 'checked="checked"' : '';
}
}
$output[$attr["id"]] .= sprintf('<input type="radio" class="input%s" name="%s" value="%s" %s /><label for="%s">%s</label>', $attr["required"] ? ' required' : '', $fieldname, $value["id"], $checked, $fieldname, $value["name"]);
}
$output[$attr["id"]] . '</fieldset>';
break;
case "select":
$output[$attr["id"]] .= sprintf("\n" . '<fieldset class="selectgroup %s"><label for="%s">%s</label>', $attr["required"] ? 'required' : '', $fieldname, stripslashes($attr["name"]));
$values_request = Sql_Query("select * from {$table_prefix}" . "listattr_" . $attr["tablename"] . " order by listorder,name");
$output[$attr["id"]] .= sprintf('<select name="%s" class="input%s">', $fieldname, $attr["required"] ? 'required' : '');
while ($value = Sql_Fetch_array($values_request)) {
if (!empty($_POST[$fieldname])) {
$selected = $_POST[$fieldname] == $value["id"] ? 'selected="selected"' : '';
} elseif ($data[$attr["id"]]) {
$selected = $data[$attr["id"]] == $value["id"] ? 'selected="selected"' : '';
} else {
$selected = $attr["default_value"] == $value["name"] ? 'selected="selected"' : '';
}
if (preg_match('/^' . preg_quote(EMPTY_VALUE_PREFIX) . '/i', $value['name'])) {
$value['id'] = '';
}
$output[$attr["id"]] .= sprintf('<option value="%s" %s>%s</option>', $value["id"], $selected, stripslashes($value["name"]));
}
$output[$attr["id"]] .= "</select>";
$output[$attr["id"]] .= "</fieldset>";
break;
case "checkboxgroup":
$output[$attr["id"]] .= sprintf("\n" . '<fieldset class="checkboxgroup %s"><label for="%s">%s</label>', $attr["required"] ? 'required' : '', $fieldname, stripslashes($attr["name"]));
$values_request = Sql_Query("select * from {$table_prefix}" . "listattr_" . $attr["tablename"] . " order by listorder,name");
$cbCounter = 0;
while ($value = Sql_Fetch_array($values_request)) {
$cbCounter++;
$selected = '';
if (is_array($_POST[$fieldname])) {
$selected = in_array($value["id"], $_POST[$fieldname]) ? 'checked="checked"' : '';
} elseif ($data[$attr["id"]]) {
$selection = explode(",", $data[$attr["id"]]);
$selected = in_array($value["id"], $selection) ? 'checked="checked"' : '';
}
$output[$attr["id"]] .= sprintf('<input type="checkbox" name="%s[]" id="%s%d" class="input%s" value="%s" %s /><label for="%s%d">%s</label>', $fieldname, $fieldname, $cbCounter, $attr["required"] ? ' required' : '', $value["id"], $selected, $fieldname, $cbCounter, stripslashes($value["name"]));
}
$output[$attr["id"]] .= '</fieldset>';
break;
case "textline":
$output[$attr["id"]] .= sprintf("\n" . '<label for="%s" class="input %s">%s</label>', $fieldname, $attr["required"] ? ' required' : '', $attr["name"]);
$output[$attr["id"]] .= sprintf('<input type="text" name="%s" class="input%s" value="%s" />', $fieldname, $attr["required"] ? ' required' : '', isset($_POST[$fieldname]) ? htmlspecialchars(stripslashes($_POST[$fieldname])) : (isset($data[$attr["id"]]) ? $data[$attr["id"]] : $attr["default_value"]));
break;
case "textarea":
$output[$attr["id"]] .= sprintf("\n" . '<label for="%s" class="input %s">%s</label>', $fieldname, $attr["required"] ? ' required' : '', $attr["name"]);
$output[$attr["id"]] .= sprintf('<textarea name="%s" rows="%d" cols="%d" class="input%s" wrap="virtual">%s</textarea>', $fieldname, $textarearows, $textareacols, $attr["required"] ? ' required' : '', isset($_POST[$fieldname]) ? htmlspecialchars(stripslashes($_POST[$fieldname])) : (isset($data[$attr["id"]]) ? htmlspecialchars(stripslashes($data[$attr["id"]])) : $attr["default_value"]));
break;
case "hidden":
$output[$attr["id"]] .= sprintf('<input type="hidden" name="%s" value="%s" />', $fieldname, $data[$attr["id"]] ? $data[$attr["id"]] : $attr["default_value"]);
break;
case "date":
require_once dirname(__FILE__) . "/date.php";
$date = new Date();
$postval = $date->getDate($fieldname);
if ($data[$attr["id"]]) {
$val = $data[$attr["id"]];
} else {
$val = $postval;
}
$output[$attr["id"]] = sprintf("\n" . '<fieldset class="date%s"><label for="%s">%s</label>', $attr["required"] ? ' required' : '', $fieldname, $attr["name"]);
$output[$attr["id"]] .= sprintf('%s', $date->showInput($fieldname, "", $val));
$output[$attr["id"]] .= '</fieldset>';
break;
default:
print "<!-- error: huh, invalid attribute type -->";
}
$output[$attr["id"]] .= "\n";
}
}
# make sure the order is correct
foreach ($attributes as $attribute => $listorder) {
if (isset($output[$attribute])) {
$html .= $output[$attribute];
}
}
$html .= '</fieldset>' . "\n";
## class=attributes
# print htmlspecialchars( '<fieldset class="phplist">'.$html.'</fieldset>');exit;
return $html;
}
示例10: modify
/**
* This method modifies an existing campaign. Undefined fields do not change
* and defined fields with a NULL value also remain unchanged.
*
* @access public
*
* @param OA_Dll_CampaignInfo &$oCampaign <br />
* <b>For adding</b><br />
* <b>Required properties:</b> advertiserId<br />
* <b>Optional properties:</b> campaignName, startDate, endDate, impressions, clicks, priority, weight<br />
*
* <b>For modify</b><br />
* <b>Required properties:</b> campaignId<br />
* <b>Optional properties:</b> advertiserId, campaignName, startDate, endDate, impressions, clicks, priority, weight, viewWindow, clickWindow<br />
*
* @return boolean True if the operation was successful
*
*/
function modify(&$oCampaign)
{
if (!isset($oCampaign->campaignId)) {
// Add
$oCampaign->setDefaultForAdd();
if (!$this->checkPermissions(array(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER), 'clients', $oCampaign->advertiserId)) {
return false;
}
} else {
// Edit
if (!$this->checkPermissions(array(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER), 'campaigns', $oCampaign->campaignId)) {
return false;
}
}
$oStartDate = $oCampaign->startDate;
$oEndDate = $oCampaign->endDate;
$campaignData = (array) $oCampaign;
$campaignData['campaignid'] = $oCampaign->campaignId;
$campaignData['campaignname'] = $oCampaign->campaignName;
$campaignData['clientid'] = $oCampaign->advertiserId;
$oNow = new Date();
if (is_object($oStartDate)) {
$oDate = new Date($oStartDate);
$oDate->setTZ($oNow->tz);
$oDate->setHour(0);
$oDate->setMinute(0);
$oDate->setSecond(0);
$oDate->toUTC();
$campaignData['activate_time'] = $oDate->getDate(DATE_FORMAT_ISO);
}
if (is_object($oEndDate)) {
$oDate = new Date($oEndDate);
$oDate->setTZ($oNow->tz);
$oDate->setHour(23);
$oDate->setMinute(59);
$oDate->setSecond(59);
$oDate->toUTC();
$campaignData['expire_time'] = $oDate->getDate(DATE_FORMAT_ISO);
}
$campaignData['views'] = $oCampaign->impressions;
$campaignData['target_impression'] = $oCampaign->targetImpressions;
$campaignData['target_click'] = $oCampaign->targetClicks;
$campaignData['target_conversion'] = $oCampaign->targetConversions;
$campaignData['revenue_type'] = $oCampaign->revenueType;
$campaignData['capping'] = $oCampaign->capping > 0 ? $oCampaign->capping : 0;
$campaignData['session_capping'] = $oCampaign->sessionCapping > 0 ? $oCampaign->sessionCapping : 0;
$campaignData['block'] = $oCampaign->block > 0 ? $oCampaign->block : 0;
$campaignData['viewwindow'] = $oCampaign->viewWindow;
$campaignData['clickwindow'] = $oCampaign->clickWindow;
if ($this->_validate($oCampaign)) {
$doCampaign = OA_Dal::factoryDO('campaigns');
if (!isset($oCampaign->campaignId)) {
$doCampaign->setFrom($campaignData);
$oCampaign->campaignId = $doCampaign->insert();
} else {
$doCampaign->get($campaignData['campaignid']);
$doCampaign->setFrom($campaignData);
$doCampaign->update();
}
return true;
} else {
return false;
}
}
示例11: Date
/**
* A method to convert a Date into an array containing the start
* and end Dates of the operation interval that the date is in.
*
* @static
* @param Date $oDate The date to convert.
* @param integer $operation_interval Optional length of the operation interval
* in minutes. If not given, will use the
* currently defined operation interval.
* @param boolean $cacheResult If true the data should be cached
* @return array An array of the start and end Dates of the operation interval.
*/
function convertDateToOperationIntervalStartAndEndDates($oDate, $operationInterval = 0, $cacheResult = true)
{
// Convert to UTC
$oDateCopy = new Date($oDate);
$oDateCopy->toUTC();
// Check cache
static $aCache;
if ($cacheResult && isset($aCache[$oDateCopy->getDate()][$operationInterval])) {
$cachedDates = $aCache[$oDateCopy->getDate()][$operationInterval];
$oStart = new Date($cachedDates['start']);
$oStart->setTZbyID('UTC');
$oEnd = new Date($cachedDates['end']);
$oEnd->setTZbyID('UTC');
return array('start' => $oStart, 'end' => $oEnd);
}
if ($operationInterval < 1) {
$operationInterval = OX_OperationInterval::getOperationInterval();
}
// Get the date representing the start of the week
$oStartOfWeek = new Date(Date_Calc::beginOfWeek($oDateCopy->getDay(), $oDateCopy->getMonth(), $oDateCopy->getYear(), '%Y-%m-%d 00:00:00'));
$oStartOfWeek->setTZbyID('UTC');
// Get the operation interval ID of the date
$operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDateCopy, $operationInterval);
// The start of the operation interval is the start of the week plus the
// operation interval ID multiplied by the operation interval
$oStart = new Date();
$oStart->copy($oStartOfWeek);
$oStart->addSeconds($operationIntervalID * $operationInterval * 60);
// The end of the operation interval is the start of the week plus the
// operation interval ID + 1 multiplied by the operation interval
$oEnd = new Date();
$oEnd->copy($oStart);
$oEnd->addSeconds($operationInterval * 60 - 1);
// Cache result - cache as string to save memory
if ($cacheResult) {
$aCache[$oDate->getDate()][$operationInterval] = array('start' => $oStart->getDate(), 'end' => $oEnd->getDate());
}
// Return the result
return array('start' => $oStart, 'end' => $oEnd);
}
示例12: 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);
//.........这里部分代码省略.........
示例13: testGetDaysLeftString
//.........这里部分代码省略.........
$doDSAH->clicks = $clicks;
$doDSAH->conversions = $conversions;
$dsahId = DataGenerator::generateOne($doDSAH);
// Delivered 50 impressions in 1 day. So, expect to take 19 days to
// deliver remaining 950
// Delivered 5 clicks in 1 day. So, expect to take 99 days to deliver
// remaining 495
// Delivered 1 conversion in 1 day. So, expect to take 9 days to deliver
// remaining 9
// The estimated expiration will be calucalated based on impression targets
// or based on click targets or based on conversion targets (following this order).
$daysLeft = 19;
$oExpirationDate = new Date();
$oExpirationDate->copy($oDate);
$oExpirationDate->addSeconds($daysLeft * SECONDS_PER_DAY);
$expected = array('estimatedExpiration' => $GLOBALS['strEstimated'] . ": " . $oExpirationDate->format('%d.%m.%Y') . " (" . $GLOBALS['strDaysLeft'] . ": " . $daysLeft . ")", 'campaignExpiration' => $GLOBALS['strNoExpiration']);
$actual = $this->oDalCampaigns->getDaysLeftString($campaignId);
$this->assertEqual($actual, $expected);
// Case 3
// Test a campaign with expiration date and without a estimated expiration date
// Prepare a date 10 days in the future
$daysLeft = 10;
$oDate = new Date();
$oDate->setHour(23);
$oDate->setMinute(59);
$oDate->setSecond(59);
$oDate->addSeconds($daysLeft * SECONDS_PER_DAY);
$oDate->toUTC();
// Test an unlimited campaign which expires 10 days in the future
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->views = 0;
$doCampaigns->clicks = 0;
$doCampaigns->conversions = 0;
$doCampaigns->expire_time = $oDate->getDate(DATE_FORMAT_ISO);
$aData = array('reportlastdate' => array('2007-04-03 18:39:45'));
$dg = new DataGenerator();
$dg->setData('clients', $aData);
$aCampaignIds = $dg->generate($doCampaigns, 1, true);
$campaignId = $aCampaignIds[0];
// Link a banner to this campaign
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $campaignId;
$doBanners->acls_updated = '2007-04-03 18:39:45';
$bannerId = DataGenerator::generateOne($doBanners);
$expected = array('estimatedExpiration' => $GLOBALS['strEstimated'] . ": " . $GLOBALS['strNoExpirationEstimation'], 'campaignExpiration' => $GLOBALS['strExpirationDate'] . ": " . $oDate->format('%d.%m.%Y') . " (" . $GLOBALS['strDaysLeft'] . ": " . $daysLeft . ")");
$actual = $this->oDalCampaigns->getDaysLeftString($campaignId);
$this->assertEqual($actual, $expected);
// Case 4
// Campaign with expiration date reached
// Prepare a campaign with expiration date reached
$daysExpired = 5;
$oDate = new Date();
$oDate->setHour(23);
$oDate->setMinute(59);
$oDate->setSecond(59);
$oDate->subtractSeconds($daysExpired * SECONDS_PER_DAY);
$oDate->toUTC();
// Test an unlimited campaign which expired 5 days ago
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->views = 0;
$doCampaigns->clicks = 0;
$doCampaigns->conversions = 0;
$doCampaigns->expire_time = $oDate->getDate(DATE_FORMAT_ISO);
$aData = array('reportlastdate' => array('2007-04-03 18:39:45'));
$dg = new DataGenerator();
$dg->setData('clients', $aData);
示例14: arrayToDate
//.........这里部分代码省略.........
// possible day values
if (isset($date_input['d'])) {
$day = $date_input['d'];
} else {
if (isset($date_input['j'])) {
$day = $date_input['j'];
}
}
// possible hour values
if (isset($date_input['g'])) {
$hour = $date_input['g'];
} else {
if (isset($date_input['h'])) {
$hour = $date_input['h'];
} else {
if (isset($date_input['G'])) {
$hour = $date_input['G'];
} else {
if (isset($date_input['H'])) {
$hour = $date_input['H'];
}
}
}
}
// possible am/pm values
if (isset($date_input['a'])) {
$ampm = $date_input['a'];
} else {
if (isset($date_input['A'])) {
$ampm = $date_input['A'];
}
}
// instantiate date object
$datestr = '';
if (isset($year) || isset($month) || isset($day)) {
if (isset($year) && !empty($year)) {
if (strlen($year) < 2) {
$year = '0' . $year;
}
if (strlen($year) < 4) {
$year = substr($year, 0, 2) . $year;
}
} else {
$year = '0000';
}
if ($year != '0000' && isset($month) && !empty($month)) {
if (strlen($month) < 2) {
$month = '0' . $month;
}
} else {
$month = '00';
}
if ($year != '0000' && $month != '00' && isset($day) && !empty($day)) {
if (strlen($day) < 2) {
$day = '0' . $day;
}
} else {
$day = '00';
}
$datestr .= "{$year}-{$month}-{$day}";
}
if (isset($hour) || isset($date_input['i']) || isset($date_input['s'])) {
// set the hour
if (isset($hour) && !empty($hour)) {
if (strlen($hour) < 2) {
$hour = '0' . $hour;
}
} else {
$hour = '00';
}
if (isset($ampm)) {
if (strtolower($ampm) == 'pm' && strlen($hour) == 1) {
$hour += 12;
}
}
// set the minutes
if (isset($date_input['i']) && !empty($date_input['i'])) {
if (strlen($date_input['i']) < 2) {
$date_input['i'] = '0' . $date_input['i'];
}
} else {
$date_input['i'] = '00';
}
$datestr .= ($datestr != '' ? ' ' : '') . "{$hour}:{$date_input['i']}";
// set the seconds
if (isset($date_input['s']) && !empty($date_input['s'])) {
$datestr .= ':' . (strlen($date_input['s']) < 2 ? '0' : '') . $date_input['s'];
} else {
$datestr .= ':00';
}
}
// feed it into the date object
$dateobj = new Date($datestr);
// set the time zone
$dateobj->setTZ(NDate::getClientTZ());
// pull the string back out
$datestr = $dateobj->getDate();
unset($dateobj);
return $datestr;
}
示例15: ListAttributes
//.........这里部分代码省略.........
} else {
if ($data[$attr["id"]]) {
$checked = $data[$attr["id"]] == $value["id"] ? "checked" : "";
} else {
$checked = $attr["default_value"] == $value["name"] ? "checked" : "";
}
}
$output[$attr["id"]] .= sprintf(' %s <input type=radio class="attributeinput" name="%s" value="%s" %s>', $value["name"], $fieldname, $value["id"], $checked);
}
if ($attr["required"]) {
$output[$attr["id"]] .= sprintf('<script language="Javascript" type="text/javascript">addGroupToCheck("%s","%s");</script>', $fieldname, $attr["name"]);
}
break;
case "select":
$output[$attr["id"]] .= sprintf("\n" . '<tr><td><div class="%s">%s</div>', $attr["required"] ? 'required' : 'attributename', stripslashes($attr["name"]));
$values_request = Sql_Query("select * from {$table_prefix}" . "listattr_" . $attr["tablename"] . " order by listorder,name");
$output[$attr["id"]] .= sprintf('</td><td class="attributeinput"><!--%d--><select name="%s" class="attributeinput">', $data[$attr["id"]], $fieldname);
while ($value = Sql_Fetch_array($values_request)) {
if (!empty($_POST[$fieldname])) {
$selected = $_POST[$fieldname] == $value["id"] ? "selected" : "";
} else {
if ($data[$attr["id"]]) {
$selected = $data[$attr["id"]] == $value["id"] ? "selected" : "";
} else {
$selected = $attr["default_value"] == $value["name"] ? "selected" : "";
}
}
if (preg_match('/^' . preg_quote(EMPTY_VALUE_PREFIX) . '/i', $value['name'])) {
$value['id'] = '';
}
$output[$attr["id"]] .= sprintf('<option value="%s" %s>%s', $value["id"], $selected, stripslashes($value["name"]));
}
$output[$attr["id"]] .= "</select>";
break;
case "checkboxgroup":
$output[$attr["id"]] .= sprintf("\n" . '<tr><td colspan=2><div class="%s">%s</div>', $attr["required"] ? 'required' : 'attributename', stripslashes($attr["name"]));
$values_request = Sql_Query("select * from {$table_prefix}" . "listattr_" . $attr["tablename"] . " order by listorder,name");
$output[$attr["id"]] .= sprintf('</td></tr>');
while ($value = Sql_Fetch_array($values_request)) {
if (is_array($_POST[$fieldname])) {
$selected = in_array($value["id"], $_POST[$fieldname]) ? "checked" : "";
} else {
if ($data[$attr["id"]]) {
$selection = explode(",", $data[$attr["id"]]);
$selected = in_array($value["id"], $selection) ? "checked" : "";
} else {
$selection = array();
$selected = "";
}
}
$output[$attr["id"]] .= sprintf('<tr><td colspan=2 class="attributeinput"><input type=checkbox name="%s[]" class="attributeinput" value="%s" %s> %s</td></tr>', $fieldname, $value["id"], $selected, stripslashes($value["name"]));
}
break;
case "textline":
$output[$attr["id"]] .= sprintf("\n" . '<tr><td><div class="%s">%s</div>', $attr["required"] ? 'required' : 'attributename', $attr["name"]);
$output[$attr["id"]] .= sprintf('</td><td class="attributeinput">
<input type=text name="%s" class="attributeinput" size="%d" value="%s">', $fieldname, $textlinewidth, $_POST[$fieldname] ? htmlspecialchars(stripslashes($_POST[$fieldname])) : ($data[$attr["id"]] ? $data[$attr["id"]] : $attr["default_value"]));
if ($attr["required"]) {
$output[$attr["id"]] .= sprintf('<script language="Javascript" type="text/javascript">addFieldToCheck("%s","%s");</script>', $fieldname, $attr["name"]);
}
break;
case "textarea":
$output[$attr["id"]] .= sprintf("\n" . '<tr><td colspan=2>
<div class="%s">%s</div></td></tr>', $attr["required"] ? 'required' : 'attributename', $attr["name"]);
$output[$attr["id"]] .= sprintf('<tr><td class="attributeinput" colspan=2>
<textarea name="%s" rows="%d" class="attributeinput" cols="%d" wrap="virtual">%s</textarea>', $fieldname, $textarearows, $textareacols, $_POST[$fieldname] ? htmlspecialchars(stripslashes($_POST[$fieldname])) : ($data[$attr["id"]] ? htmlspecialchars(stripslashes($data[$attr["id"]])) : $attr["default_value"]));
if ($attr["required"]) {
$output[$attr["id"]] .= sprintf('<script language="Javascript" type="text/javascript">addFieldToCheck("%s","%s");</script>', $fieldname, $attr["name"]);
}
break;
case "hidden":
$output[$attr["id"]] .= sprintf('<input type=hidden name="%s" size=40 value="%s">', $fieldname, $data[$attr["id"]] ? $data[$attr["id"]] : $attr["default_value"]);
break;
case "date":
require_once dirname(__FILE__) . "/date.php";
$date = new Date();
$postval = $date->getDate($fieldname);
if ($data[$attr["id"]]) {
$val = $data[$attr["id"]];
} else {
$val = $postval;
}
$output[$attr["id"]] = sprintf("\n" . '<tr><td><div class="%s">%s</div>', $attr["required"] ? 'required' : 'attributename', $attr["name"]);
$output[$attr["id"]] .= sprintf('</td><td class="attributeinput">
%s</td></tr>', $date->showInput($fieldname, "", $val));
break;
default:
print "<!-- error: huh, invalid attribute type -->";
}
$output[$attr["id"]] .= "</td></tr>\n";
}
}
# make sure the order is correct
foreach ($attributes as $attribute => $listorder) {
if (isset($output[$attribute])) {
$html .= $output[$attribute];
}
}
return $html;
}