本文整理汇总了PHP中SS_Datetime::create_field方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_Datetime::create_field方法的具体用法?PHP SS_Datetime::create_field怎么用?PHP SS_Datetime::create_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_Datetime
的用法示例。
在下文中一共展示了SS_Datetime::create_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LatestTweetsList
public function LatestTweetsList($limit = '5')
{
$conf = SiteConfig::current_site_config();
if (empty($conf->TwitterName) || empty($conf->TwitterConsumerKey) || empty($conf->TwitterConsumerSecret) || empty($conf->TwitterAccessToken) || empty($conf->TwitterAccessTokenSecret)) {
return new ArrayList();
}
$cache = SS_Cache::factory('LatestTweets_cache');
if (!($results = unserialize($cache->load(__FUNCTION__)))) {
$results = new ArrayList();
require_once dirname(__FILE__) . '/tmhOAuth/tmhOAuth.php';
require_once dirname(__FILE__) . '/tmhOAuth/tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array('consumer_key' => $conf->TwitterConsumerKey, 'consumer_secret' => $conf->TwitterConsumerSecret, 'user_token' => $conf->TwitterAccessToken, 'user_secret' => $conf->TwitterAccessTokenSecret, 'curl_ssl_verifypeer' => false));
$code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $conf->TwitterName, 'count' => $limit));
$tweets = $tmhOAuth->response['response'];
$json = new JSONDataFormatter();
if (($arr = $json->convertStringToArray($tweets)) && is_array($arr) && isset($arr[0]['text'])) {
foreach ($arr as $tweet) {
try {
$here = new DateTime(SS_Datetime::now()->getValue());
$there = new DateTime($tweet['created_at']);
$there->setTimezone($here->getTimezone());
$date = $there->Format('Y-m-d H:i:s');
} catch (Exception $e) {
$date = 0;
}
$results->push(new ArrayData(array('Text' => nl2br(tmhUtilities::entify_with_options($tweet, array('target' => '_blank'))), 'Date' => SS_Datetime::create_field('SS_Datetime', $date))));
}
}
$cache->save(serialize($results), __FUNCTION__);
}
return $results;
}
示例2: _getRSS
public function _getRSS()
{
$allItems = ArrayList::create();
$feeds = $this->widget->RSSFeeds->getValues();
if ($feeds && count($feeds)) {
foreach ($feeds as $feedUrl) {
$feed = new RestfulService($feedUrl, 1800);
$request = $feed->request();
// Make sure the request ended up being a success.
if (substr($request->getStatusCode(), 0, 1) == '2') {
$XML = $request->simpleXML($request->getBody());
$objects = $this->recursiveXML($XML);
$output = null;
// Make sure the XML is valid RSS.
if (isset($objects['channel']['item'])) {
$output = $objects['channel']['item'];
} else {
if (isset($objects['entry'])) {
$output = $objects['entry'];
}
}
if ($output) {
// Transform the XML into a structure that templating can parse.
$output = ArrayList::create($output);
foreach ($output as $child) {
// the foreach triggers the conversion to ArrayData - we're going to grab them
// into the main array list now
// and add a Time field for sorting later
$date = $child->pubDate ? $child->pubDate : $child->updated;
$child->pubTime = strtotime($date);
$child->ItemDate = SS_Datetime::create_field('SS_Datetime', $child->pubTime);
$link = $child->link;
if ($link instanceof ArrayData) {
$link = $link->toMap();
$child->link = $link['@attributes']['href'];
}
$allItems->push($child);
}
}
}
}
}
return $allItems->sort('pubTime', 'DESC');
}