本文整理汇总了PHP中TimeHelper::getDayOfYear方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeHelper::getDayOfYear方法的具体用法?PHP TimeHelper::getDayOfYear怎么用?PHP TimeHelper::getDayOfYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeHelper
的用法示例。
在下文中一共展示了TimeHelper::getDayOfYear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetClearDayOfYear
public function testSetClearDayOfYear()
{
$start = TimeHelper::getDayOfYear();
$this->assertNotEqual($start, 400);
//not more than 365 days in a year
TimeHelper::setDayOfYear(450);
$now = TimeHelper::getDayOfYear();
$this->assertEqual(450, $now);
TimeHelper::clearDayOfYear();
$now = TimeHelper::getDayOfYear();
$this->assertNotEqual(450, $now);
}
示例2: sendDigestSinceWithTemplate
/**
* Send out insight email digest for a given time period.
* @param Owner $owner Owner to send for
* @param str $start When to start insight lookup
* @param str $template Email view template to use
* @param array $options Plugin options
* @param bool $weekly Is this a weekly email?
* return bool Whether email was sent
*/
private function sendDigestSinceWithTemplate($owner, $start, $template, &$options, $weekly)
{
$insights_dao = DAOFactory::GetDAO('InsightDAO');
$start_time = date('Y-m-d H:i:s', strtotime($start, $this->current_timestamp));
$insights = $insights_dao->getAllOwnerInstanceInsightsSince($owner->id, $start_time);
$num_insights = count($insights);
if ($num_insights == 0) {
return false;
}
$config = Config::getInstance();
$view = new ViewManager();
$view->caching = false;
$logger = Logger::getInstance();
// If we've got a Mandrill key and template, send HTML
if ($config->getValue('mandrill_api_key') != null && !empty($options['mandrill_template'])) {
$logger->logUserInfo("Mandrill API key and template set; sending HTML", __METHOD__ . ',' . __LINE__);
$view->assign('insights', $insights);
$view->assign('application_url', Utils::getApplicationURL());
$view->assign('header_text', $this->getEmailMessageHeaderText());
if (Utils::isThinkUpLLC()) {
$logger->logUserInfo("Email via ThinkUpLLC, process welcome / free trial messaging", __METHOD__ . ',' . __LINE__);
$thinkupllc_endpoint = $config->getValue('thinkupllc_endpoint');
$view->assign('thinkupllc_endpoint', $thinkupllc_endpoint);
$view->assign('unsub_url', $thinkupllc_endpoint . 'settings.php');
$view->assign('install_folder', $config->getValue('install_folder'));
if (!isset($options['last_daily_email'])) {
$logger->logUserInfo("No daily email ever sent before, include welcome message", __METHOD__ . ',' . __LINE__);
$view->assign('show_welcome_message', true);
} else {
if ($owner->is_free_trial) {
$logger->logUserInfo("Owner is in free trial", __METHOD__ . ',' . __LINE__);
$creation_date = new DateTime($owner->joined);
$now = new DateTime();
$end_of_trial = $creation_date->add(new DateInterval('P15D'));
if ($end_of_trial >= $now) {
$interval = $now->diff($end_of_trial);
$days_left = $interval->format('%a');
if ($days_left > 2) {
$view->assign('pay_prompt_headline', $days_left . ' days left in your free trial!');
} elseif ($days_left == 0) {
//Last day
$view->assign('pay_prompt_headline', 'Last chance!');
} else {
//Show hours if it's 24 or 48 hours
$view->assign('pay_prompt_headline', 'Only ' . $days_left * 24 . ' hours left!');
}
$explainer_copy_options = array("Your free trial expires today. Don't lose any of your insights!", "It's time to become a member. We'd love to have you.", "It's just " . ($owner->membership_level == 'Member' ? '16' : '32') . " cents a day to get smarter about the time you spend online.", "Isn't this better than boring \"analytics\"?", "Just wait 'til you see ThinkUp next week.", "We never sell your data and we don't show you ads.", "Get our exclusive book on the future of social media for free.", "ThinkUp gives you social network superpowers.", "The longer you use ThinkUp, the smarter it gets.", "ThinkUp helps you be more thoughtful about your time online.", "ThinkUp works in email, on the web, and on all your devices.", "ThinkUp members can cancel at any time—with no hassles.", 'Wait until you see what ThinkUp has in store tomorrow.', "Your morning ThinkUp email will make your day.");
$view->assign('pay_prompt_explainer', $explainer_copy_options[$days_left]);
if ($owner->membership_level == 'Member') {
$view->assign('pay_prompt_button_label', 'Just $5/month');
} elseif ($owner->membership_level == 'Pro') {
$view->assign('pay_prompt_button_label', 'Just $10/month');
}
}
} else {
//Check subscription status and show a message if Payment failed or due
$logger->logUserInfo("User is not in free trial; check subscription status", __METHOD__ . ',' . __LINE__);
$thinkupllc_api_accessor = new ThinkUpLLCAPIAccessor();
$membership_details = $thinkupllc_api_accessor->getSubscriptionStatus($owner->email);
$logger->logUserInfo("Subscription status is " . Utils::varDumpToString($membership_details), __METHOD__ . ',' . __LINE__);
if (isset($membership_details->subscription_status) && ($membership_details->subscription_status == 'Payment failed' || $membership_details->subscription_status == 'Payment due')) {
$logger->logUserInfo("Owner has payment failure; include alert in email", __METHOD__ . ',' . __LINE__);
$payment_failed_copy = array();
if ($membership_details->subscription_status == 'Payment failed') {
$payment_failed_copy[] = array('headline' => 'Oops! Your account needs attention', 'explainer' => "We had a problem processing your membership payment. " . "But it's easy to fix.");
$payment_failed_copy[] = array('headline' => 'Uh oh, problem with your subscription...', 'explainer' => "There was a problem processing your membership payment. " . "To fix it, update your payment info.");
$payment_failed_copy[] = array('headline' => 'Your ThinkUp subscription is out of date...', 'explainer' => "We tried to charge your Amazon account for your ThinkUp membership," . " and there was an error. But it's easy to fix.");
$payment_failed_copy[] = array('headline' => 'Action required to keep your ThinkUp account active', 'explainer' => "We weren't able to process your last membership payment—maybe your " . "info is out of date? Fixing it just takes a moment.");
$payment_failed_copy[] = array('headline' => "Urgent! Keep your ThinkUp account active", 'explainer' => "We tried to process your ThinkUp subscription, but " . "the payment was not successful. Please update your payment information " . "now to make sure your ThinkUp membership stays in good standing.");
$payment_failed_button_label = "Update your payment info";
} else {
//Payment due
$payment_failed_copy[] = array('headline' => 'Oops! Your ThinkUp membership needs attention', 'explainer' => "Looks like you've got a membership payment due. " . "But it's easy to make it.");
$payment_failed_copy[] = array('headline' => "Uh-oh, don't let your subscription expire", 'explainer' => "Looks like your ThinkUp payment is due. " . "Make it now so your account doesn't expire.");
$payment_failed_copy[] = array('headline' => 'Hey, your ThinkUp subscription payment is due', 'explainer' => "Your membership payment isn't up-to-date. " . " But it's easy to fix.");
$payment_failed_copy[] = array('headline' => 'Action required: Keep your ThinkUp account active', 'explainer' => "Looks like you've got a membership payment due. " . "Making it just takes a moment.");
$payment_failed_copy[] = array('headline' => "Urgent! Keep your ThinkUp account active", 'explainer' => "Your subscription payment is due. " . "Please update your information now to keep your ThinkUp membership " . "in good standing.");
$payment_failed_button_label = "Make your payment";
}
$copy_index = TimeHelper::getDayOfYear() % count($payment_failed_copy);
$payment_failed_headline = $payment_failed_copy[$copy_index]['headline'];
$payment_failed_explainer = $payment_failed_copy[$copy_index]['explainer'];
$view->assign('payment_failed_headline', $payment_failed_headline);
$view->assign('payment_failed_explainer', $payment_failed_explainer);
$view->assign('payment_failed_button_label', $payment_failed_button_label);
}
}
}
$thinkupllc_email_tout = $config->getValue('thinkupllc_email_tout');
if (isset($thinkupllc_email_tout)) {
$view->assign('thinkupllc_email_tout', $thinkupllc_email_tout);
//.........这里部分代码省略.........