本文整理汇总了PHP中TimeHelper类的典型用法代码示例。如果您正苦于以下问题:PHP TimeHelper类的具体用法?PHP TimeHelper怎么用?PHP TimeHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimeHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: item
/**
* Creates an item for the sitemap or sitemap index
*
* @param array $options various options pertaining to the item
* @return string The item
* @author Jose Diaz-Gonzalez
**/
public function item($options = array())
{
$options = array_merge(array('loc' => NULL, 'lastmod' => NULL, 'changefreq' => NULL, 'priority' => NULL, 'encode' => true), $options);
if (!empty($options['loc'])) {
if (!empty($options['lastmod'])) {
$time = new TimeHelper();
$options['lastmod'] = $time->toAtom($options['lastmod']);
}
if ($options['encode']) {
$options['loc'] = $this->_xmlspecialchars($options['loc']);
}
if ($this->sitemap) {
//Construct a sitemapindex item
$item = array();
$item['openEntity'] = "<sitemap>";
$item['loc'] = $this->_entityMaker("loc", $options['loc']);
$item['lastmod'] = $this->_entityMaker("lastmod", $options['lastmod']);
$item['closeEntity'] = "</sitemap>\n";
return $this->_mergeArrayEntities($item);
} else {
//Construct a sitemap item
$item = array();
$item['openEntity'] = "<url>";
$item['loc'] = $this->_entityMaker("loc", $options['loc']);
$item['lastmod'] = $this->_entityMaker("lastmod", $options['lastmod']);
$item['changefreq'] = $this->_entityMaker("changefreq", $options['changefreq']);
$item['priority'] = $this->_entityMaker("priority", $options['priority']);
$item['closeEntity'] = "</url>\n";
return $this->_mergeArrayEntities($item);
}
}
return false;
}
开发者ID:josegonzalez,项目名称:cakephp-sitemap,代码行数:40,代码来源:sitemap.php
示例2: index
function index()
{
$this->layout = 'cart';
$this->loadModel('MasterCategory');
$masterCategories = $this->MasterCategory->find('all', array('order' => array('MasterCategory.priority'), 'recursive' => -1));
$this->Category->Behaviors->attach('Containable');
foreach ($masterCategories as &$masterCategory) {
$products = $this->Category->find('all', array('contain' => array('Product' => array('conditions' => array('AND' => array('Product.display = ' => '1', 'Product.stock > ' => '0', 'Product.master_category_id' => $masterCategory['MasterCategory']['id'])))), 'order' => 'Category.priority'));
$masterCategory['Products'] = $products;
}
$this->set('products', $masterCategories);
$this->loadModel('Configuration');
$isSiteClosed = $this->Configuration->findByKeyAndOrganizationId('closed', $this->currentUser['User']['organization_id']);
if ($isSiteClosed == "yes") {
$closed = true;
$nextDelivery = $this->Delivery->find('first', array('conditions' => array('Delivery.next_delivery' => true)));
App::import('Helper', 'Time');
$time = new TimeHelper();
$nextDeliveryDate = $time->format($format = 'd-m-Y', $nextDelivery['Delivery']['date'], null, "+7.0");
$this->set('nextDeliveryDate', $nextDeliveryDate);
} else {
$closed = false;
}
$this->set('closed', $closed);
}
开发者ID:sunny36,项目名称:grecocos,代码行数:25,代码来源:carts_controller.php
示例3: get_recent_orders
function get_recent_orders()
{
$time = new TimeHelper();
$dayAgo = time() - 86400;
$formatedDayAgo = $time->format("Y-m-d H:i:s", $dayAgo);
$result = $this->find('all', array('conditions' => array('od_date >=' => $formatedDayAgo)));
return $result;
}
开发者ID:johnulist,项目名称:ecommerce,代码行数:8,代码来源:order.php
示例4: _isLastMonth
function _isLastMonth()
{
App::import('Helper', 'Time');
$time = new TimeHelper();
$last_month[0] = date('Y-m-01', strtotime('-1 month'));
$last_month[1] = date(DATE_W3C, mktime(0, 0, 0, date('m'), 0, date('y')));
$q = $time->daysAsSql($last_month[0], $last_month[1], 'modified');
$res = false;
if ($this->SbmRanking->hasAny($q)) {
$res = true;
}
return $res;
}
开发者ID:hide99,项目名称:sbmranking,代码行数:13,代码来源:sbmranking.php
示例5: testAlternateText
public function testAlternateText()
{
TimeHelper::setTime(3);
// Get data ready that insight requires
$builders = self::buildDataTeens();
$instance = new Instance();
$instance->id = 100;
$instance->network_user_id = 1;
$instance->network_username = 'Teen Dude';
$instance->network = 'facebook';
$post_dao = new PostMySQLDAO();
$last_week_of_posts = $post_dao->getAllPostsByUsernameOrderedBy($instance->network_username, $network = $instance->network, $count = 0, $order_by = "pub_date", $in_last_x_days = $number_days, $iterator = false, $is_public = false);
$insight_plugin = new AgeAnalysisInsight();
$insight_plugin->generateInsight($instance, null, $last_week_of_posts, 5);
// Assert that insight got inserted
$insight_dao = new InsightMySQLDAO();
$today = date('Y-m-d');
$result = $insight_dao->getInsight('age_analysis', 100, $today);
$related_data = unserialize($result->related_data);
$this->assertNotNull($result);
$this->assertIsA($result, "Insight");
$this->assertEqual($result->headline, 'Teens said it all');
$this->assertEqual($result->text, "Teens — people less than 18 years old — wrote 100% of the " . "comments on Teen Dude's Facebook posts this week.");
$this->assertEqual($related_data['age_data']['18'], 2);
$this->assertEqual($related_data['age_data']['18_25'], 0);
$this->assertEqual($related_data['age_data']['25_35'], 0);
$this->assertEqual($related_data['age_data']['35_45'], 0);
$this->assertEqual($related_data['age_data']['45'], 0);
$result->id = 1;
$this->debug($this->getRenderedInsightInHTML($result));
$this->debug($this->getRenderedInsightInEmail($result));
}
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:32,代码来源:TestOfAgeAnalysisInsight.php
示例6: generateInsight
public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$baseline_dao = DAOFactory::getDAO('InsightBaselineDAO');
foreach ($this->getSchedule() as $baseline_slug => $data) {
$now = TimeHelper::getTime();
if ($now >= strtotime($data['start']) && $now <= strtotime($data['end'])) {
$this->logger->logInfo("{$now} is in-schedule", __METHOD__ . ',' . __LINE__);
$baseline = $baseline_dao->getMostRecentInsightBaseline($baseline_slug, $instance->id);
if (!$baseline) {
if ($instance->network == 'facebook' && date('w') == 4 || $instance->network == 'twitter' && date('w') == 1 || Utils::isTest()) {
$found = $this->runInsightForConfig($data, $instance);
$baseline_dao->insertInsightBaseline($baseline_slug, $instance->id, $found);
} else {
$this->logger->logInfo("Not today", __METHOD__ . ',' . __LINE__);
}
} else {
$this->logger->logInfo("Already exists", __METHOD__ . ',' . __LINE__);
}
} else {
$this->logger->logInfo("Not in-schedule", __METHOD__ . ',' . __LINE__);
}
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:26,代码来源:newdictionarywords.php
示例7: generateInsight
public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$possible_messaging = array(array('headline' => 'Ohai', 'text' => 'Greetings, humans', 'header_image' => 'http://farm3.staticflickr.com/2713/4098259769_725b5fb65b_o.jpg'), array('headline' => 'Hello', 'text' => 'Greetings, earthlings', 'header_image' => 'http://farm9.staticflickr.com/8078/8276342554_5a51725f5f_n.jpg'), array('headline' => 'Yo', 'text' => 'Greetings, peeps', 'header_image' => 'http://farm6.staticflickr.com/5006/5367216303_83c5f2dc39_n.jpg'));
//Instantiate the Insight object
$my_insight = new Insight();
//REQUIRED: Set the insight's required attributes
//We pull some from the options above. But the could just be strings like 'Ohai'
$which_messaging = TimeHelper::getTime() % count($possible_messaging);
foreach ($possible_messaging[$which_messaging] as $field => $value) {
$my_insight->{$field} = $value;
}
$my_insight->slug = 'my_test_insight_hello_thinkup';
//slug to label this insight's content
$my_insight->instance_id = $instance->id;
$my_insight->date = $this->insight_date;
//date is often this or $simplified_post_date
$my_insight->filename = basename(__FILE__, ".php");
//Same for every insight, must be set exactly this way
$my_insight->emphasis = Insight::EMPHASIS_MED;
//Set emphasis optionally, default is Insight::EMPHASIS_LOW
//OPTIONAL: Attach related data of various types using Insight setter functions
//$my_insight->setPosts($my_insight_posts);
//$my_insight->setLinks($my_insight_links);
//$my_insight->setPeople($my_insight_people);
//$my_insight->setMilestones($my_insight_milestones);
//etc
$this->insight_dao->insertInsight($my_insight);
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:31,代码来源:hellothinkupinsight.php
示例8: testHelloThinkUpInsight
public function testHelloThinkUpInsight()
{
$posts = array();
$instance = new Instance();
$instance->id = 1;
$instance->network_username = 'Katniss Everdeen';
$instance->network = 'facebook';
$builders = self::setUpPublicInsight($instance);
// We have three random options, so we'll check each one here.
TimeHelper::setTime(3);
$hello_thinkup_insight_plugin = new HelloThinkUpInsight();
$hello_thinkup_insight_plugin->generateInsight($instance, null, $posts, 3);
$insight_dao = DAOFactory::getDAO('InsightDAO');
$result = $insight_dao->getInsight('my_test_insight_hello_thinkup', 1, date('Y-m-d'));
$this->assertEqual($result->headline, 'Ohai');
$this->assertEqual($result->text, 'Greetings, humans');
$this->assertEqual($result->filename, 'hellothinkupinsight');
$this->assertNull($result->related_data);
$this->assertEqual($result->emphasis, Insight::EMPHASIS_MED);
TimeHelper::setTime(4);
$hello_thinkup_insight_plugin->generateInsight($instance, null, $posts, 3);
$insight_dao = DAOFactory::getDAO('InsightDAO');
$result = $insight_dao->getInsight('my_test_insight_hello_thinkup', 1, date('Y-m-d'));
$this->assertEqual($result->headline, 'Hello');
$this->assertEqual($result->text, 'Greetings, earthlings');
TimeHelper::setTime(5);
$hello_thinkup_insight_plugin->generateInsight($instance, null, $posts, 3);
$insight_dao = DAOFactory::getDAO('InsightDAO');
$result = $insight_dao->getInsight('my_test_insight_hello_thinkup', 1, date('Y-m-d'));
$this->assertEqual($result->headline, 'Yo');
$this->assertEqual($result->text, 'Greetings, peeps');
/**
* Use this code to output the individual insight's fully-rendered HTML to file.
* Then, open the file in your browser to view.
*
* $ TEST_DEBUG=1 php webapp/plugins/insightsgenerator/tests/TestOfHelloThinkUpInsight.php
* -t testHelloThinkUpInsight > webapp/insight.html
*/
$controller = new InsightStreamController();
$_GET['u'] = 'Katniss Everdeen';
$_GET['n'] = 'facebook';
$_GET['d'] = date('Y-m-d');
$_GET['s'] = 'my_test_insight_hello_thinkup';
$results = $controller->go();
//Uncomment this out to see web view of insight
//$this->debug($results);
/**
* Use this code to output the individual insight's fully-rendered email HTML to file.
* Then, open the file in your browser to view.
*
* $ TEST_DEBUG=1 php webapp/plugins/insightsgenerator/tests/TestOfHelloThinkUpInsight.php
* -t testHelloThinkUpInsight > webapp/insight_email.html
*/
$email_insight = $this->getRenderedInsightInEmail($result);
//Uncomment this out to see the email view of insight
//$this->debug($email_insight);
}
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:57,代码来源:TestOfHelloThinkUpInsight.php
示例9: __get
public function __get($format)
{
if (in_array($format, TimeHelper::$formats)) {
return TimeHelper::to_string($format, $this->time);
}
if (in_array($format, DateHelper::$formats)) {
return DateHelper::to_string($format, $this->time);
}
}
开发者ID:scottdavis,项目名称:active_php,代码行数:9,代码来源:time.php
示例10: sendEmailSiteReopen
function sendEmailSiteReopen()
{
$User = ClassRegistry::init('User');
$users = $User->find('all', array('conditions' => array('User.status' => 'accepted')));
foreach ($users as $user) {
$to = $to . $user['User']['email'] . ", ";
}
$subject = "GRECOCOS website is now open";
$Delivery = ClassRegistry::init('Delivery');
$nextDelivery = $Delivery->findByNextDelivery(true);
App::import('Helper', 'Time');
$timeHelper = new TimeHelper();
$deliveryDate = $timeHelper->format($format = 'd-m-Y', $nextDelivery['Delivery']['date']);
$body = "<p>Dear member</p>" . "<p>The GRECOCOS website is opened. " . "You can place your orders now for delivery on " . "{$deliveryDate}.</p>" . "<p><a href=\"http://grecocos.co.cc/index.php\">" . "http://grecocos.co.cc/index.php</a></p>";
$AppengineEmail = ClassRegistry::init('AppengineEmail');
$AppengineEmail->sendEmail($to, $subject, $body);
$this->Session->write('sendEmailReOpenSite', true);
}
开发者ID:sunny36,项目名称:grecocos,代码行数:18,代码来源:configurations_controller.php
示例11: reset_user_password
function reset_user_password($key = null)
{
if (!empty($this->data)) {
$user = $this->Ticket->findUser($this->data['Ticket']['email']);
$hasTicket = $this->Ticket->find('first', array('conditions' => array('Ticket.email' => $user['User']['email'])));
//pr($hasTicket);
//die;
if (!empty($user) && empty($hasTicket)) {
App::import('Helper', 'Time');
$time = new TimeHelper();
$key = Security::hash(String::uuid(), 'sha1', true);
$this->data['Ticket']['key'] = $key;
$this->data['Ticket']['creation_date'] = $time->format('Y-m-d H:i:s', time());
$url = Router::url(array('controller' => 'tickets', 'action' => 'reset_user_password'), true) . '/' . $key;
//pr($url);
//die;
//ko se ticket shrani v bazo se poslje email (email element: lost_password_notification.ctp) useru, ki je ticket odprl
if ($this->Ticket->save($this->data)) {
$this->set('url', $url);
$this->MyEmail->sendResetPasswordEmail($user['User']['email']);
$this->Session->setFlash('notification email has been sent to you with reset data');
}
} elseif (!empty($hasTicket)) {
if ($this->Ticket->checkTicketDateValidity($hasTicket)) {
$this->Session->setFlash('We had already sent you a link to your email address! Go get it, lazy ass!');
} else {
$this->Session->setFlash('Your ticket regarding lost password has been deleted due to expiration! Try submitting again');
}
}
//se prozi kadar user klikne link, ki vsebuje generiran key, v svojem mailu in ga redirecta sem
} elseif (isset($key) && !empty($key)) {
$result = $this->Ticket->find('first', array('conditions' => array('Ticket.key' => $key)));
$this->Ticket->checkTicketDateValidity($result);
if (!empty($result)) {
$user = $this->Ticket->findUser($result['Ticket']['email']);
$this->set('userId', $user['User']['id']);
$this->set('key', $key);
$this->Ticket->delete($result['Ticket']['id']);
//$this->redirect(array('controller' => 'users', 'action' => 'changeUserPassword/uid:'.$user['User']['id']));
}
} else {
$this->Session->setFlash('Please provide your email!');
}
}
开发者ID:johnulist,项目名称:ecommerce,代码行数:44,代码来源:tickets_controller.php
示例12: time_ago_in_words
public function time_ago_in_words($from_time, $include_seconds = false)
{
$now_gmt = new \DateTime("now", new \DateTimeZone("UTC"));
if (in_array(get_class($from_time), array("DateTime", "ActiveRecord\\DateTime"))) {
$from_gmt = clone $from_time;
$from_gmt->setTimezone(new \DateTimeZone("UTC"));
} elseif (is_int($from_time)) {
$from_gmt = new \DateTime("@" . $from_time, new \DateTimeZone("UTC"));
}
return TimeHelper::distance_of_time_in_words($from_gmt, $now_gmt, $include_seconds);
}
开发者ID:jcs,项目名称:halfmoon,代码行数:11,代码来源:time_helper.php
示例13: setUp
public function setUp()
{
parent::setUp();
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = 42;
$instance->network_username = 'testy';
$instance->network = 'twitter';
$this->instance = $instance;
TimeHelper::setTime(1425329077);
// Set it to the March 2015 words timeframe
}
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:12,代码来源:TestOfNewDictionaryWordsInsight.php
示例14: setUp
public function setUp()
{
parent::setUp();
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = 42;
$instance->network_username = 'testy';
$instance->network = 'twitter';
$this->instance = $instance;
TimeHelper::setTime(1418947200);
// Set it to the December 2014 words timeframe
}
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:12,代码来源:TestOfEOYWordsOfYearInsight.php
示例15: setUp
public function setUp()
{
parent::setUp();
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = 42;
$instance->network_username = 'bookworm';
$instance->network = 'twitter';
$this->instance = $instance;
$this->insight_dao = DAOFactory::getDAO('InsightDAO');
TimeHelper::setTime(2);
// Force one headline for most tests
}
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:13,代码来源:TestOfTopWordsInsight.php
示例16: generateInsight
public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$year = date('Y');
$regenerate = false;
//testing
//$regenerate = true;
$should_generate_insight = self::shouldGenerateEndOfYearAnnualInsight($this->slug, $instance, $insight_date = "{$year}-{$this->run_date}", $regenerate, $day_of_year = $this->run_date, null, $excluded_networks = array('twitter'));
if ($should_generate_insight) {
$this->logger->logInfo("Should generate", __METHOD__ . ',' . __LINE__);
$fav_dao = DAOFactory::getDAO('FavoritePostDAO');
$fans = $fav_dao->getUsersWhoFavoritedMostOfYourPosts($instance->network_user_id, $instance->network, TimeHelper::getDaysSinceJanFirst());
if (!isset($fans) || sizeof($fans) == 0) {
$this->logger->logInfo("No fans captured", __METHOD__ . ',' . __LINE__);
return;
}
$post_dao = DAOFactory::getDAO('PostDAO');
$earliest_pub_date = $post_dao->getEarliestCapturedPostPubDate($instance);
$qualified_year = ".";
if (date('Y', strtotime($earliest_pub_date)) == date('Y')) {
if (date('n', strtotime($earliest_pub_date)) > 1) {
//not January
//Earliest post was this year; figure out what month we have data since this year
$since = date('F', strtotime($earliest_pub_date));
$qualified_year = " (at least since " . $since . ").";
}
}
$insight = new Insight();
$insight->instance_id = $instance->id;
$insight->slug = $this->slug;
$insight->date = "{$year}-{$this->run_date}";
$network = $instance->network;
$copy = array('facebook' => array('normal' => array('headline' => "%username's biggest Facebook fans of %year", 'body' => "It feels great to have friends who support you. " . "%user_list liked %username's status updates the most this year%qualified_year")), 'instagram' => array('normal' => array('headline' => "%username's biggest Instagram fans of %year", 'body' => "It means a lot to have friends who love your stuff. " . "%user_list liked %username's Instagram photos and videos the most this year%qualified_year")));
$type = 'normal';
$headline = $this->getVariableCopy(array($copy[$network][$type]['headline']), array('year' => $year));
$fan_list = array();
foreach ($fans as $fan) {
$fan_list[] = $fan->full_name;
}
$fan_list = $this->makeList($fan_list);
$insight_text = $this->getVariableCopy(array($copy[$network][$type]['body']), array('user_list' => $fan_list, 'qualified_year' => $qualified_year));
$insight->headline = $headline;
$insight->text = $insight_text;
$insight->setPeople($fans);
$insight->filename = basename(__FILE__, ".php");
$insight->emphasis = Insight::EMPHASIS_HIGH;
$this->insight_dao->insertInsight($insight);
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:51,代码来源:eoybiggestfans.php
示例17: generateInsight
public function generateInsight(Instance $instance, User $user, $last_week_of_posts, $number_days)
{
parent::generateInsight($instance, $user, $last_week_of_posts, $number_days);
$this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
$year = date('Y');
$regenerate = false;
//testing
//$regenerate = true;
$should_generate_insight = self::shouldGenerateEndOfYearAnnualInsight($this->slug, $instance, $insight_date = "{$year}-{$this->run_date}", $regenerate, $day_of_year = $this->run_date);
if ($should_generate_insight) {
$this->logger->logInfo("Should generate", __METHOD__ . ',' . __LINE__);
$post_dao = DAOFactory::getDAO('PostDAO');
$days = TimeHelper::getDaysSinceJanFirst();
$bestie = $post_dao->getBestie($instance, $days);
if (isset($bestie)) {
$type = 'normal';
} else {
$type = 'none';
}
$earliest_pub_date = $post_dao->getEarliestCapturedPostPubDate($instance);
$qualified_year = "";
if (date('Y', strtotime($earliest_pub_date)) == date('Y')) {
if (date('n', strtotime($earliest_pub_date)) > 1) {
//not January
//Earliest post was this year; figure out what month we have data since this year
$since = date('F', strtotime($earliest_pub_date));
$qualified_year = " (at least since " . $since . ")";
}
}
$insight = new Insight();
$insight->instance_id = $instance->id;
$insight->slug = $this->slug;
$insight->date = "{$year}-{$this->run_date}";
$network = $instance->network;
$copy = array('twitter' => array('normal' => array('headline' => "%username's Twitter bestie of %year", 'body' => "Nobody likes tweeting into the void. %username and @%bestie made Twitter a " . "void-free place to tweet this year. %username tweeted at @%bestie " . "<strong>%u_to_b times</strong> in 2015, and @%bestie replied " . "<strong>%b_to_u times</strong>%qualified_year. OMG you two!"), 'none' => array('headline' => "%username's Twitter bestie of %year", 'body' => "%username didn't reply to any one person more than 3 times " . "this year%qualified_year. That means no one can claim the title of %username's Twitter " . "bestie. Playing hard-to-get, huh?")), 'facebook' => array('normal' => array('headline' => "%username's Facebook bestie of %year", 'body' => "Everyone loves getting comments from their friends. In 2015, %bestie commented " . "on %username's status updates <strong>%b_to_u times</strong>, more than " . "anyone else%qualified_year. Best friends forever!"), 'none' => array('headline' => "%username's Facebook bestie of %year", 'body' => "%username's friends must consider %username's words definitive - no one replied " . "more than three times to %username's status updates all year%qualified_year.")), 'instagram' => array('normal' => array('headline' => "%username's Instagram bestie of %year", 'body' => "Everyone loves getting comments from their friends. In 2015, %bestie commented " . "on %username's Instagram photos and videos <strong>%b_to_u times</strong>, more than " . "anyone else%qualified_year. Best friends forever!"), 'none' => array('headline' => "%username's Instagram bestie of %year", 'body' => "%username's photos and videos left %username's friends speechless - no one replied " . "more than three times to %username's Instagram posts all year%qualified_year.")));
$headline = $this->getVariableCopy(array($copy[$network][$type]['headline']), array('year' => $year));
$insight_text = $this->getVariableCopy(array($copy[$network][$type]['body']), array('bestie' => isset($bestie['user_name']) ? $bestie['user_name'] : "", 'u_to_b' => isset($bestie['total_replies_to']) ? $bestie['total_replies_to'] : "", 'b_to_u' => isset($bestie['total_replies_from']) ? $bestie['total_replies_from'] : "", 'qualified_year' => $qualified_year));
$insight->headline = $headline;
$insight->text = $insight_text;
$insight->filename = basename(__FILE__, ".php");
$insight->emphasis = Insight::EMPHASIS_HIGH;
if (isset($bestie['avatar'])) {
$insight->header_image = $bestie['avatar'];
}
$this->insight_dao->insertInsight($insight);
}
$this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
}
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:48,代码来源:eoybestie.php
示例18: testNoHealthyShareLikes
public function testNoHealthyShareLikes()
{
// Get data ready that insight requires
$instance = new Instance();
$instance->id = 10;
$instance->network_username = 'testeriffic';
$instance->network = 'twitter';
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 5, 'retweet_count_cache' => 15, 'favlike_count_cache' => 3));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 5, 'favlike_count_cache' => 15));
$posts[] = new Post(array('reply_count_cache' => 2, 'retweet_count_cache' => 5, 'favlike_count_cache' => 1));
$insight_dao = new InsightMySQLDAO();
$insight_plugin = new ResponseTimeInsight();
TimeHelper::setTime(2);
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('response_time', 10, date('Y-m-d'));
$this->assertEqual("That's a healthy share of the 21 million tweets each hour.", $result->text);
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 5, 'retweet_count_cache' => 15, 'favlike_count_cache' => 13));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 5, 'favlike_count_cache' => 15));
$posts[] = new Post(array('reply_count_cache' => 2, 'retweet_count_cache' => 5, 'favlike_count_cache' => 15));
TimeHelper::setTime(2);
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('response_time', 10, date('Y-m-d'));
$this->assertNotEqual("That's a healthy share of the 21 million tweets each hour.", $result->text);
}
开发者ID:Nitin216,项目名称:ThinkUp,代码行数:26,代码来源:TestOfResponseTimeInsight.php
示例19: testVariableFuckCountInHeadline
public function testVariableFuckCountInHeadline()
{
TimeHelper::setTime(3);
$insight_dao = DAOFactory::getDAO('InsightDAO');
$post_builders = array();
$post_builders[] = FixtureBuilder::build('posts', array('author_username' => 'testy', 'network' => 'twitter', 'post_text' => 'fuck', 'pub_date' => date('Y-m-d')));
$post_builders[] = FixtureBuilder::build('posts', array('author_username' => 'testy', 'network' => 'facebook', 'post_text' => 'fuck', 'pub_date' => date('Y-m-d')));
$insight_plugin = new FBombCountInsight();
$today = date('Y-m-d');
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$result = $insight_dao->getInsight($insight_plugin->getSlug(), $this->instance->id, $today);
$this->assertEqual($result->headline, '@testy really gave a fuck');
$post_builders[] = FixtureBuilder::build('posts', array('author_username' => 'testy', 'network' => 'twitter', 'post_text' => 'fuck', 'pub_date' => date('Y-m-d')));
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$result = $insight_dao->getInsight($insight_plugin->getSlug(), $this->instance->id, $today);
$this->assertEqual($result->headline, 'F-bombs rain from the sky');
TimeHelper::setTime(1);
}
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:18,代码来源:TestOfFBombCountInsight.php
示例20: secure_url
echo $settings->enable_https ? secure_url('post') : URL::to('post');
echo '/' . $post->slug;
?>
">
<div class="thumbnail-overlay"></div>
<img src="<?php
echo ImageHandler::getImage($post->image, 'medium');
?>
">
<div class="details">
<h2><?php
echo $post->title;
?>
</h2>
<span><?php
echo TimeHelper::convert_seconds_to_HMS($post->duration);
?>
</span>
</div>
</a>
<div class="block-contents">
<p class="date"><?php
echo date("F jS, Y", strtotime($post->created_at));
?>
</p>
<p class="desc"><?php
if (strlen($post_description) > 90) {
echo substr($post_description, 0, 90) . '...';
} else {
echo $post->description;
}
开发者ID:rinodung,项目名称:hello-video-laravel,代码行数:31,代码来源:post-loop.php
注:本文中的TimeHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论