当前位置: 首页>>代码示例>>PHP>>正文


PHP SS_Datetime::create_field方法代码示例

本文整理汇总了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;
 }
开发者ID:unisolutions,项目名称:silverstripe-latesttweets,代码行数:32,代码来源:LaTw_Page_Controller_Extension.php

示例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');
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-intranet-sis,代码行数:44,代码来源:AnnouncementDashlet.php


注:本文中的SS_Datetime::create_field方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。