本文整理汇总了PHP中CASHSystem::formatTimeAgo方法的典型用法代码示例。如果您正苦于以下问题:PHP CASHSystem::formatTimeAgo方法的具体用法?PHP CASHSystem::formatTimeAgo怎么用?PHP CASHSystem::formatTimeAgo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CASHSystem
的用法示例。
在下文中一共展示了CASHSystem::formatTimeAgo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTumblrFeed
public function getTumblrFeed($tumblr_domain, $start_at = 0, $tagged = false, $post_types = false)
{
if ($tumblr_domain) {
$default_post_types = array('regular' => true, 'link' => true, 'quote' => false, 'photo' => true, 'conversation' => false, 'video' => true, 'audio' => true, 'answer' => false);
if (is_array($post_types)) {
$final_post_types = array_merge($default_post_types, $post_types);
} else {
$final_post_types = $default_post_types;
}
$tumblr_domain = str_replace(array('http://', '/'), '', $tumblr_domain);
$tumblr_url = 'http://' . $tumblr_domain . '/api/read/json?start=' . $start_at . '&num=30';
if ($tagged) {
$tumblr_url .= '&tagged=' . urlencode($tagged);
}
$feed_data = $this->getCachedURL('com.tumblr', 'domain_' . str_replace('.', '', $tumblr_domain) . $start_at, $tumblr_url, 'raw', false);
if ($feed_data) {
// tumblr's funny, JSONP only, so we cache its return and strip of some extra
$feed_data = str_replace('var tumblr_api_read = ', '', $feed_data);
// strip off the variable declaration
$feed_data = substr($feed_data, 0, strlen($feed_data) - 2);
// and the trailing semicolon+newline
// decode the trimmed content, then return just the posts
$feed_data = json_decode($feed_data);
$feed_data = $feed_data->posts;
// make a dummy array to save final posts
$final_feed_data = array();
// loop through all the posts, filter by type
foreach ($feed_data as $post) {
if ($final_post_types[$post->type]) {
$post->formatted_date = CASHSystem::formatTimeAgo($post->{'unix-timestamp'});
$final_feed_data[] = $post;
}
}
$feed_data = $final_feed_data;
}
return $feed_data;
} else {
return false;
}
}
示例2: test_formatTimeAgo
function test_formatTimeAgo()
{
$return_date = CASHSystem::formatTimeAgo(time() - 90000);
$return_hours = CASHSystem::formatTimeAgo(time() - 25000);
$return_1hour = CASHSystem::formatTimeAgo(time() - 5000);
$return_minutes = CASHSystem::formatTimeAgo(time() - 2500);
$return_1minute = CASHSystem::formatTimeAgo(time() - 90);
$return_seconds = CASHSystem::formatTimeAgo(time() - 45);
$give_string_return = CASHSystem::formatTimeAgo(date('d M Y h:i:s A', time() - 5000));
$this->assertPattern('/^[0-9]{2} [A-Za-z]{3}/', $return_date);
// > 1 day returns a 'd M' formatted date
$this->assertPattern('/hours/', $return_hours);
// between 2 and 24 hours
$this->assertEqual('1 hour ago', $return_1hour);
// 1 hour ago (fuzzy)
$this->assertPattern('/minutes/', $return_minutes);
// between 2 and 59 minutes
$this->assertEqual('1 minute ago', $return_1minute);
// 1 minute ago (fuzzy)
$this->assertPattern('/seconds/', $return_seconds);
// between 1 and 59 seconds ago
$this->assertEqual('1 hour ago', $give_string_return);
// give a string, parse, get a string
}
示例3: array_merge
// parsing posted data:
if (isset($_POST['docampaignedit'])) {
// do the actual list add stuffs...
$edit_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'editcampaign', 'id' => $request_parameters[0], 'title' => $_POST['campaign_title'], 'description' => $_POST['campaign_description']));
if ($edit_response['status_uid'] == 'element_editcampaign_200') {
AdminHelper::formSuccess('Success. Edited.', '/');
} else {
AdminHelper::formFailure('Error. There was a problem editing your campaign.', '/');
}
}
$current_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getcampaign', 'id' => $request_parameters[0]));
$cash_admin->page_data['ui_title'] = 'Campaigns: Edit "' . $current_response['payload']['title'] . '"';
$current_campaign = $current_response['payload'];
if (is_array($current_campaign)) {
$cash_admin->page_data = array_merge($cash_admin->page_data, $current_campaign);
}
$cash_admin->page_data['form_state_action'] = 'docampaignedit';
$cash_admin->page_data['button_text'] = 'Save changes';
$elements_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getelementsforcampaign', 'id' => $request_parameters[0]));
if (is_array($elements_response['payload'])) {
foreach ($elements_response['payload'] as &$element) {
if ($element['modification_date'] == 0) {
$element['formatted_date'] = CASHSystem::formatTimeAgo($element['creation_date']);
} else {
$element['formatted_date'] = CASHSystem::formatTimeAgo($element['modification_date']);
}
}
$cash_admin->page_data['elements_for_campaign'] = new ArrayIterator($elements_response['payload']);
}
$cash_admin->setPageContentTemplate('campaign_edit');
示例4: implode
$variant_descriptions[] = "{$key}: {$value}";
}
$item['variant'] = implode(', ', $variant_descriptions);
}
}
if ($o['gross_price'] - $item_price) {
$shipping_cost = CASHSystem::getCurrencySymbol($o['currency']) . number_format($o['gross_price'] - $item_price, 2);
$item_price = CASHSystem::getCurrencySymbol($o['currency']) . number_format($item_price, 2);
} else {
$shipping_cost = false;
}
$customer_name = $o['customer_shipping_name'];
if (!$customer_name) {
$customer_name = $o['customer_name'];
}
$all_order_details[] = array('id' => $o['id'], 'customer_name' => $customer_name, 'customer_email' => $o['customer_email'], 'customer_address1' => $o['customer_address1'], 'customer_address2' => $o['customer_address2'], 'customer_city' => $o['customer_city'], 'customer_region' => $o['customer_region'], 'customer_postalcode' => $o['customer_postalcode'], 'customer_country' => $o['customer_country'], 'number' => '#' . str_pad($o['id'], 6, 0, STR_PAD_LEFT), 'date' => CASHSystem::formatTimeAgo((int) $order_date, true), 'order_description' => str_replace("\n", ' ', $o['order_description']), 'order_contents' => $order_contents, 'shipping' => $shipping_cost, 'itemtotal' => $item_price, 'gross' => CASHSystem::getCurrencySymbol($o['currency']) . number_format($o['gross_price'], 2), 'fulfilled' => $o['fulfilled'], 'notes' => $o['notes']);
}
}
if (count($all_order_details) > 0) {
if (count($all_order_details) > 10) {
$cash_admin->page_data['show_pagination'] = true;
$cash_admin->page_data['show_next'] = true;
if ($cash_admin->page_data['show_previous']) {
$cash_admin->page_data['show_nextandprevious'] = true;
}
array_pop($all_order_details);
}
$cash_admin->page_data['orders_recent'] = new ArrayIterator($all_order_details);
$cash_admin->page_data['show_filters'] = true;
}
}
示例5: array
<?php
$all_order_details = false;
$orders_response = $cash_admin->requestAndStore(array('cash_request_type' => 'commerce', 'cash_action' => 'getordersforuser', 'user_id' => $cash_admin->effective_user_id));
if (is_array($orders_response['payload'])) {
$all_order_details = array();
foreach ($orders_response['payload'] as $order) {
if ($order['canceled'] == 0) {
$order_details_response = $cash_admin->requestAndStore(array('cash_request_type' => 'commerce', 'cash_action' => 'getorder', 'id' => $order['id'], 'deep' => true));
$order_details = $order_details_response['payload'];
if ($order_details['successful']) {
$order_date = $order_details['creation_date'];
if ($order_details['creation_date']) {
$order_date = $order_details['modification_date'];
}
$all_order_details[] = array('id' => '#' . str_pad($order_details['id'], 6, 0, STR_PAD_LEFT), 'date' => CASHSystem::formatTimeAgo((int) $order_date) . '<br /><a href="' . ADMIN_WWW_BASE_PATH . '/commerce/orders/view/' . $order_details['id'] . '">details</a>', 'customer' => $order_details['customer_details']['display_name'] . '<br /><a href="mailto:' . $order_details['customer_details']['email_address'] . '">' . $order_details['customer_details']['email_address'] . '</a>', 'items' => str_replace('\\n', '<br />', $order_details['order_totals']['description']), 'gross' => '$' . sprintf("%01.2f", $order_details['gross_price']), 'net' => '$' . sprintf("%01.2f", $order_details['gross_price'] - $order_details['service_fee']));
}
}
}
if (count($all_order_details) > 0) {
$cash_admin->page_data['all_order_details'] = new ArrayIterator($all_order_details);
}
}
$cash_admin->setPageContentTemplate('commerce_orders');
示例6: prepMarkup
public function prepMarkup($tweet)
{
$tmp_profile_img = $tweet->user->profile_image_url;
if ($tmp_profile_img == 'http://static.twitter.com/images/default_profile_normal.png') {
$tmp_profile_img = 'http://a2.twimg.com/sticky/default_profile_images/default_profile_' . rand(0, 6) . '_normal.png';
}
$innermarkup = "<div class=\"cashmusic_social cashmusic_twitter cashmusic_twitter_" . $tweet->user->screen_name . "\"><img src=\"{$tmp_profile_img}\" class=\"cashmusic_twitter_avatar\" alt=\"avatar\" />" . "<div class=\"cashmusic_twitter_namespc\"><a href=\"http://twitter.com/" . $tweet->user->screen_name . "\">@" . $tweet->user->screen_name . "</a><br />" . $tweet->user->name . "</div><div class=\"cashmusic_clearall\">.</div>" . "<div class=\"tweet\">" . CASHSystem::linkifyText($tweet->text, true) . '<div class="cashmusic_social_date"><a href="http://twitter.com/#!/' . $tweet->user->screen_name . '/status/' . $tweet->id_str . '" target="_blank">' . CASHSystem::formatTimeAgo($tweet->created_at) . ' / twitter</a> </div></div>' . "</div>";
return $innermarkup;
/*
The CSS to go along with the twitter markup:
From our stuff up on http://marketairglovamusic.com/
.cashmusic_social {margin:10px 0 20px 0;padding:15px;background-color:#fff;border-top-left-radius:5px 5px;border-top-right-radius:5px 5px;border-bottom-right-radius:5px 5px;border-bottom-left-radius:5px 5px;}
.cashmusic_social a {color:#cdcdcd;}
.cashmusic_twitter {font:14.5px/1.75em georgia,'times new roman',times,serif;}
.cashmusic_twitter_avatar {float:left;margin:1px 8px 8px 0;}
.cashmusic_twitter_namespc {color:#cdcdcd;font:11px/1.5em helvetica,"helvetica neue",arial,sans-serif;}
.cashmusic_twitter_namespc a {color:#007e3d;font:bold 15px/1.85em helvetica,"helvetica neue",arial,sans-serif;}
.cashmusic_twitter a {color:#007e3d;}
.cashmusic_tumblr h2, .cashmusic_tumblr h2 a, #topmenu * a, h2 {color:#111;font:28px/1em 'IM Fell English',georgia,'times new roman',times,serif;}
.cashmusic_social_date {margin-top:10px;color:#cdcdcd;font:11px/1.75em helvetica,"helvetica neue",arial,sans-serif;}
.cashmusic_clearall {clear:both;height:1px;overflow:hidden;visibility:hidden;}
*/
}
示例7: prepMarkup
public function prepMarkup($post, $summarize = false)
{
$innermarkup = false;
switch ($post->type) {
case 'regular':
if ($summarize) {
$textbody = '';
$textbodyarray = explode('.', strip_tags($post->{'regular-body'}));
if (count($textbodyarray) > 3) {
$textbodyarray = array_slice($textbodyarray, 0, 3);
}
$textbody = implode('.', $textbodyarray) . '...';
} else {
$textbody = $post->{'regular-body'};
}
$innermarkup = "<div class=\"cashmusic_social cashmusic_tumblr\">" . '<h2><a href="' . $post->{'url-with-slug'} . '" target="_blank">' . $post->{$post->type . '-title'} . '</a></h2><div>' . $textbody . '</div><div class="cashmusic_social_date"><a href="' . $post->{'url-with-slug'} . '" target="_blank">' . CASHSystem::formatTimeAgo($post->{'unix-timestamp'}) . ' / tumblr</a> </div>' . '<div class="cashmusic_clearall">.</div></div>';
break;
case 'photo':
$innermarkup = "<div class=\"cashmusic_social cashmusic_tumblr\">" . '<div class="cashmusic_social_photo"><img src="' . $post->{'photo-url-500'} . '" width="100%" alt="" /><br />' . $post->{'photo-caption'} . '</div><div class="cashmusic_social_date"><a href="' . $post->{'url-with-slug'} . '" target="_blank">' . CASHSystem::formatTimeAgo($post->{'unix-timestamp'}) . ' / tumblr</a> </div>' . '<div class="cashmusic_clearall">.</div></div>';
break;
case 'video':
$innermarkup = "<div class=\"cashmusic_social cashmusic_tumblr\">" . '<div class="cashmusic_social_video"><div class="cashmusic_social_video_container">' . $post->{'video-player'} . '</div><br />' . $post->{'video-caption'} . '</div><div class="cashmusic_social_date"><a href="' . $post->{'url-with-slug'} . '" target="_blank">' . CASHSystem::formatTimeAgo($post->{'unix-timestamp'}) . ' / tumblr</a> </div>' . '<div class="cashmusic_clearall">.</div></div>';
break;
case 'audio':
$innermarkup = "<div class=\"cashmusic_social cashmusic_tumblr\">" . '<div class="cashmusic_social_audio"><a><div class="cashmusic_social_audio_container">' . $post->{'audio-player'} . '</div><br />' . $post->{'audio-caption'} . '</div><div class="cashmusic_social_date"><a href="' . $post->{'url-with-slug'} . '" target="_blank">' . CASHSystem::formatTimeAgo($post->{'unix-timestamp'}) . ' / tumblr</a> </div>' . '<div class="cashmusic_clearall">.</div></div>';
break;
case 'link':
$innermarkup = "<div class=\"cashmusic_social cashmusic_tumblr\">" . '<div class="cashmusic_social_link"><a href="' . $post->{'link-url'} . '">' . $post->{'link-text'} . '</a></div><div class="cashmusic_social_date"><a href="' . $post->{'url-with-slug'} . '" target="_blank">' . CASHSystem::formatTimeAgo($post->{'unix-timestamp'}) . ' / tumblr</a> </div>' . '<div class="cashmusic_clearall">.</div></div>';
break;
case 'answer':
$innermarkup = "<div class=\"cashmusic_social cashmusic_tumblr\">" . '<div class="cashmusic_social_answer"><span class="cashmusic_social_answer_q">' . $post->question . '</span><span class="cashmusic_social_answer_a">' . $post->answer . '</span></div><div class="cashmusic_social_date"><a href="' . $post->{'url-with-slug'} . '" target="_blank">' . CASHSystem::formatTimeAgo($post->{'unix-timestamp'}) . ' / tumblr</a> </div>' . '<div class="cashmusic_clearall">.</div></div>';
break;
case 'quote':
$innermarkup = "<div class=\"cashmusic_social cashmusic_tumblr\">" . '<div class="cashmusic_social_quote"><span class="cashmusic_social_quote">' . $post->{'quote-text'} . '</span><span class="cashmusic_social_quote_src">' . $post->{'quote-source'} . '</span></div><div class="cashmusic_social_date"><a href="' . $post->{'url-with-slug'} . '" target="_blank">' . CASHSystem::formatTimeAgo($post->{'unix-timestamp'}) . ' / tumblr</a> </div>' . '<div class="cashmusic_clearall">.</div></div>';
break;
}
return $innermarkup;
/*
The CSS to go along with the video container:
Thanks to http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
echo '<style type="text/css">';
echo '.cashmusic_video_container {position:relative;padding-bottom:56.25%;padding-top:30px;height:0;overflow:hidden;}';
echo '.cashmusic_video_container iframe, .cashmusic_video_container object, .cashmusic_video_container embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
echo '</style>';
*/
}
示例8: ArrayIterator
$cash_admin->page_data['featured_playlists'] = new ArrayIterator($featured_playlists);
if (count($playlists_response['payload']) > 6) {
$remaining_playlists = array_slice($playlists_response['payload'],6);
$cash_admin->page_data['more_playlists'] = true;
$cash_admin->page_data['remaining_playlists'] = new ArrayIterator($remaining_playlists);
}
}
*/
if (is_array($files_response['payload'])) {
$files_response['payload'] = array_reverse($files_response['payload']);
// newest first
foreach ($files_response['payload'] as &$asset) {
if ($asset['modification_date']) {
$asset['descriptor_string'] = 'updated: ' . CASHSystem::formatTimeAgo($asset['modification_date']);
} else {
$asset['descriptor_string'] = 'updated: ' . CASHSystem::formatTimeAgo($asset['creation_date']);
}
if (is_array($items_response['payload'])) {
foreach ($items_response['payload'] as $item) {
if ($item['fulfillment_asset'] == $asset['id']) {
$asset['monetized'] = true;
break;
}
}
}
}
$featured_files = array_slice($files_response['payload'], 0, 5);
if (count($files_response['payload']) > 5) {
$remaining_files = array_slice($files_response['payload'], 5);
$cash_admin->page_data['more_files'] = true;
$cash_admin->page_data['remaining_files'] = new ArrayIterator($remaining_files);
示例9: getCachedAPIResponse
protected function getCachedAPIResponse($endpoint, $params)
{
$data_name = http_build_query($params, '', '-');
$data = $this->getCacheData($this->settings_type, $data_name);
if (!$data && $this->twitter) {
$data = $this->twitter->get($endpoint, $params);
if (!$data) {
$data = $this->getCacheData($this->settings_type, $data_name, true);
} else {
foreach ($data as $tweet) {
// add formatted time to tweet
$tweet->formatted_created_at = CASHSystem::formatTimeAgo($tweet->created_at);
if ($tweet->user->profile_image_url_https === true) {
$tweet->user->profile_image_url_https_bigger = 'https://a0.twimg.com/sticky/default_profile_images/default_profile_1_bigger.png';
} else {
$tweet->user->profile_image_url_https_bigger = str_replace('_normal', '_bigger', $tweet->user->profile_image_url_https);
}
// handle url links
$twitterstatus = true;
if (isset($tweet->entities)) {
if (isset($tweet->entities->urls)) {
if (count($tweet->entities->urls)) {
$twitterstatus = $tweet->entities->urls;
}
}
}
$tweet->text = CASHSystem::linkifyText($tweet->text, $twitterstatus);
// add media collections
// handle twitter photos
if (isset($tweet->extended_entities)) {
if (is_object($tweet->extended_entities)) {
if (is_array($tweet->extended_entities->media)) {
$tweet->photos = array();
foreach ($tweet->extended_entities->media as $m) {
$tweet->photos[] = $m;
}
}
}
}
// handle youtube videos
if (isset($tweet->entities)) {
if (is_object($tweet->entities)) {
if (is_array($tweet->entities->urls)) {
$tweet->iframes = array();
foreach ($tweet->entities->urls as $u) {
if (strpos($u->expanded_url, 'youtube.com') > 0) {
$parsed_url = parse_url($u->expanded_url);
$query_array = array();
parse_str($parsed_url['query'], $query_array);
if (isset($query_array['v'])) {
$tweet->iframes[] = array('iframe_url' => '//www.youtube.com/embed/' . $query_array['v']);
// <iframe src="//www.youtube.com/embed/dOy7vPwEtCw" frameborder="0" allowfullscreen></iframe>
}
}
}
}
}
}
}
$this->setCacheData($this->settings_type, $data_name, $data);
}
}
return $data;
}
示例10: count
// set element count
$campaign['element_count'] = count($campaign['elements']);
if ($campaign['template_id'] == 0) {
$campaign['show_wizard'] = true;
}
// add campaign to dropdown options
$cash_admin->page_data['campaigns_as_options'] .= '<option value="' . $campaign['id'] . '"';
if ($campaign['id'] == $current_campaign) {
$cash_admin->page_data['campaigns_as_options'] .= ' selected="selected"';
}
$cash_admin->page_data['campaigns_as_options'] .= '>' . $campaign['title'] . '</option>';
// normalize modification/creation dates
if ($campaign['modification_date'] == 0) {
$campaign['formatted_date'] = CASHSystem::formatTimeAgo($campaign['creation_date']);
} else {
$campaign['formatted_date'] = CASHSystem::formatTimeAgo($campaign['modification_date']);
}
if ($campaign['id'] == $current_campaign) {
// get campaign analytics
$analytics_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getanalyticsforcampaign', 'id' => $campaign['id']));
$campaign['formatted_views'] = CASHSystem::formatCount(0 + $analytics_response['payload']['total_views']);
// set the campaign as the selected campaign
$cash_admin->page_data['selected_campaign'] = $campaign;
}
}
}
if ($cash_admin->page_data['template_id']) {
foreach ($campaigns_response['payload'] as &$campaign) {
if ($campaign['template_id'] == $cash_admin->page_data['template_id']) {
$campaign['currently_published'] = true;
}