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


PHP HabariDateTime::create方法代码示例

本文整理汇总了PHP中HabariDateTime::create方法的典型用法代码示例。如果您正苦于以下问题:PHP HabariDateTime::create方法的具体用法?PHP HabariDateTime::create怎么用?PHP HabariDateTime::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HabariDateTime的用法示例。


在下文中一共展示了HabariDateTime::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filter_blogroll_update_cron

    /**
     * Grabs update times from weblogs.com
     * @todo use update time from weblogs.com instead of gmdate.
     * @todo parse urls so we search for only '%host.domain.tld/path%' with no http://
     */
    public function filter_blogroll_update_cron($success)
    {
        if (Options::get('blogroll__use_updated')) {
            $request = new RemoteRequest('http://rpc.weblogs.com/changes.xml', 'GET');
            $request->add_header(array('If-Modified-Since', Options::get('blogroll__last_update')));
            try {
                if ($request->execute()) {
                    try {
                        $xml = new \SimpleXMLElement($request->get_response_body());
                    } catch (\Exception $e) {
                        EventLog::log('Could not parse weblogs.com Changes XML file');
                        return false;
                    }
                    $atts = $xml->attributes();
                    $updated = strtotime((string) $atts['updated']);
                    foreach ($xml->weblog as $weblog) {
                        $atts = $weblog->attributes();
                        $match = array();
                        $match['url'] = (string) $atts['url'];
                        $match['feedurl'] = (string) $atts['rssUrl'];
                        $update = $updated - (int) $atts['when'];
                        // use LIKE for info matching
                        $posts = DB::get_results('SELECT * FROM {posts}
							WHERE
							{posts}.id IN (
								SELECT post_id FROM {postinfo}
								WHERE ( (name = ? AND value LIKE ? ) OR (name = ? AND value LIKE ? ) )
							)
							AND status = ? AND content_type = ?', array('url', "%{$match['url']}%", 'feedurl', "%{$match['feedurl']}%", Post::status('published'), Post::type(self::CONTENT_TYPE)), 'Post');
                        if ($posts instanceof Posts && $posts->count() > 0) {
                            foreach ($posts as $post) {
                                $post->updated = HabariDateTime::create($update);
                                $post->update();
                                EventLog::log("Updated {$post->title} last update time from weblogs.com");
                            }
                        }
                    }
                    Options::set('blogroll__last_update', gmdate('D, d M Y G:i:s e'));
                    return true;
                } else {
                    EventLog::log('Could not connect to weblogs.com');
                    return false;
                }
            } catch (\Exception $e) {
                EventLog::log('Could not connect to weblogs.com (request failed)', 'error', 'default', 'Blogroll', $e);
                return false;
            }
        }
        return $success;
    }
开发者ID:habari-extras,项目名称:blogroll,代码行数:55,代码来源:blogroll.plugin.php


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