本文整理汇总了PHP中parse_w3cdtf函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_w3cdtf函数的具体用法?PHP parse_w3cdtf怎么用?PHP parse_w3cdtf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_w3cdtf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_modifier_rss_date_parse
function smarty_modifier_rss_date_parse($rss_date, $default_date = null)
{
if ($rss_date != '') {
return parse_w3cdtf($rss_date);
} elseif (isset($default_date) && $default_date != '') {
return parse_w3cdtf($default_date);
} else {
return;
}
}
示例2: getRss
/**
* Récupère le flux RSS à partir d'une URL.
* Utilise MagpieRss http://magpierss.sourceforge.net/
*/
public function getRss($url, $nbMax = -1)
{
$arFeeds = array();
// Test and Create rss temp_dir
$cachePath = COPIX_CACHE_PATH . 'fluxrss/';
$cacheTestFile = 'rss.txt';
if (!file_exists($cachePath . $cacheTestFile)) {
require_once COPIX_UTILS_PATH . 'CopixFile.class.php';
$objectWriter = new CopixFile();
$objectWriter->write($cachePath . $cacheTestFile, date('Y/m/d H:i'));
}
// Use Magpie to parse current RSS file
define('MAGPIE_CACHE_DIR', COPIX_CACHE_PATH . 'rss');
require_once 'rss_fetch.inc';
$rss = fetch_rss($url);
if ($rss) {
if ($nbMax > 0) {
$arFeeds = array_slice($rss->items, 0, intval($nbMax));
} else {
$arFeeds = $rss->items;
}
}
foreach ($arFeeds as $key => $Feed) {
//print_r($Feed);
if (isset($Feed['dc']['date'])) {
$currentDate = @parse_w3cdtf($Feed['dc']['date']);
// Ok with dotclear that uses w3c date format
//var_dump($currentDate);
} else {
$currentDate = -1;
}
if ($currentDate != -1) {
$Feed['dc']['datecopix'] = date("Ymd", $currentDate);
if (!isset($Feed['date_timestamp'])) {
$Feed['date_timestamp'] = $currentDate;
}
} else {
if (isset($Feed['date_timestamp'])) {
// Ok with b2evolution that uses timestamp format
$Feed['dc']['datecopix'] = date('Ymd', $Feed['date_timestamp']);
} else {
$Feed['dc']['datecopix'] = null;
$Feed['date_timestamp'] = null;
}
}
//var_dump($Feed);
//die();
$arFeeds[$key] = $Feed;
}
return $arFeeds;
}
示例3: MagpieRSSDate
function MagpieRSSDate($item)
{
# by http://www.pmwiki.org/wiki/Profiles/Mike
$date = "";
$rss_2_date = $item['pubdate'];
$rss_1_date = $item['dc']['date'];
$rss_3_date = $item['prism']['publicationDate'];
$atom_date = $item['issued'];
if ($atom_date != "") {
$date = parse_w3cdtf($atom_date);
}
if ($rss_1_date != "") {
$date = parse_w3cdtf($rss_1_date);
}
if ($rss_2_date != "") {
$date = strtotime($rss_2_date);
}
if ($rss_3_date != "") {
$date = parse_w3cdtf($rss_3_date);
}
if ($date == '-1') {
if ($atom_date != "") {
$date = strtotime($atom_date);
}
if ($rss_1_date != "") {
$date = strtotime($rss_1_date);
}
if ($rss_3_date != "") {
$date = strtotime($rss_3_date);
}
}
if ($date != "" && $date != '-1') {
$secondsinaday = 60 * 60 * 24;
$dateformat = 'd M Y';
$today = time();
$yesterday = time() - $secondsinaday;
$datetoday = date($dateformat, $today);
$dateyesterday = date($dateformat, $yesterday);
$daterss = date($dateformat, $date);
if ($daterss == $datetoday || $daterss == $dateyesterday) {
$color = 'red';
} else {
$color = 'gray';
}
return '<div class="magpie-date" style="color:' . $color . '">' . $daterss . '</div>';
}
return '';
}
示例4: getUnixTimestamp
public static function getUnixTimestamp($item)
{
$rss_2_date = $item['pubdate'];
$rss_1_date = $item['dc']['date'];
$atom_date = $item['issued'];
if ($atom_date != "") {
$date = parse_w3cdtf($atom_date);
}
if ($rss_1_date != "") {
$date = parse_w3cdtf($rss_1_date);
}
if ($rss_2_date != "") {
$date = strtotime($rss_2_date);
}
return $date;
}
示例5: rss_fetch_date_format
function rss_fetch_date_format($format, $item)
{
global $L_DATE_PATTERN;
$date = "";
if (isset($item['date_timestamp'])) {
$date = date($format, $item['date_timestamp']);
} else {
if (isset($item['dc']['date'])) {
$date = date($format, parse_w3cdtf($item['dc']['date']));
} else {
if (isset($item['pubdate'])) {
if (preg_match($L_DATE_PATTERN, $item['pubdate'])) {
$date = date($format, parse_w3cdtf(conv_date($item['pubdate'])));
} else {
// "$item['pubdate']"を上で変換出来なかった時はそのまま表示
$date = $item['pubdate'];
}
}
}
}
return $date;
}
示例6: foreach
$_echo_LT5 = " (LT5!)";
}
foreach ($feed->items as $item) {
$check_sql = $sql = $ftime = $flink = $ftitle = $fdesc = '';
$we_have_a_date = TRUE;
if (@(!($flink = $item['link']))) {
$flink = $item['guid'];
}
$time = dst_test(time());
if (isset($item['pubdate'])) {
$stamp = bug_free_strtotime($item['pubdate']);
$stamp = dst_test($stamp);
$ftime = date("Y-m-d", $stamp) . "T" . date("H:i:s+01:00", $stamp);
$_date_from = "pubdate";
} elseif (isset($item['dc']['date'])) {
$stamp = parse_w3cdtf($item['dc']['date']);
$stamp = dst_test($stamp);
$ftime = date("Y-m-d", $stamp) . "T" . date("H:i:s+01:00", $stamp);
$_date_from = "dc:date";
} else {
$stamp = $time;
$ftime = date("Y-m-d", $stamp) . "T" . date("H:i:s+01:00", $stamp);
$we_have_a_date = FALSE;
$_date_from = "time()";
}
if (@(!($ftitle = $item['title']))) {
$ftitle = substr(strip_tags($fdesc), 0, 25) . "...";
}
$ftitle = str_replace("'", "\\'", $ftitle);
if (@(!($fdesc = $item['content']['encoded']))) {
if (@(!($fdesc = $item['description']))) {
示例7: define
define('MAGPIE_DIR', '/home/kellan/projs/magpierss/');
require_once MAGPIE_DIR . 'rss_fetch.inc';
require_once MAGPIE_DIR . 'rss_utils.inc';
// optionally show lots of debugging info
# define('MAGPIE_DEBUG', 2);
// optionally flush cache quickly for debugging purposes,
// don't do this on a live site
# define('MAGPIE_CACHE_AGE', 10);
// use cache? default is yes. see rss_fetch for other Magpie options
# define('MAGPIE_CACHE_ON', 1)
// setup template object
$smarty = new Smarty();
$smarty->compile_check = true;
// url of an rss file
$url = htmlspecialchars($_GET['rss_url'], ENT_QUOTES);
if ($url) {
// assign a variable to smarty for use in the template
$smarty->assign('rss_url', $url);
// use MagpieRSS to fetch remote RSS file, and parse it
$rss = fetch_rss($url);
// if fetch_rss returned false, we encountered an error
if (!$rss) {
$smarty->assign('error', magpie_error());
}
$smarty->assign('rss', $rss);
$item = $rss->items[0];
$date = parse_w3cdtf($item['dc']['date']);
$smarty->assign('date', $date);
}
// parse smarty template, and display using the variables we assigned
$smarty->display('simple.smarty');
示例8: update_rss_feed
//.........这里部分代码省略.........
}
} else {
$entry_guid = $item["id"];
if (!$entry_guid) {
$entry_guid = $item["guid"];
}
if (!$entry_guid) {
$entry_guid = $item["about"];
}
if (!$entry_guid) {
$entry_guid = $item["link"];
}
if (!$entry_guid) {
$entry_guid = make_guid_from_title($item["title"]);
}
}
if ($debug_enabled) {
_debug("update_rss_feed: guid {$entry_guid}");
}
if (!$entry_guid) {
continue;
}
$entry_timestamp = "";
if ($use_simplepie) {
$entry_timestamp = strtotime($item->get_date());
} else {
$rss_2_date = $item['pubdate'];
$rss_1_date = $item['dc']['date'];
$atom_date = $item['issued'];
if (!$atom_date) {
$atom_date = $item['updated'];
}
if ($atom_date != "") {
$entry_timestamp = parse_w3cdtf($atom_date);
}
if ($rss_1_date != "") {
$entry_timestamp = parse_w3cdtf($rss_1_date);
}
if ($rss_2_date != "") {
$entry_timestamp = strtotime($rss_2_date);
}
}
if ($entry_timestamp == "" || $entry_timestamp == -1 || !$entry_timestamp) {
$entry_timestamp = time();
$no_orig_date = 'true';
} else {
$no_orig_date = 'false';
}
$entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
if ($debug_enabled) {
_debug("update_rss_feed: date {$entry_timestamp} [{$entry_timestamp_fmt}]");
}
if ($use_simplepie) {
$entry_title = $item->get_title();
} else {
$entry_title = trim(strip_tags($item["title"]));
}
if ($use_simplepie) {
$entry_link = $item->get_link();
} else {
// strange Magpie workaround
$entry_link = $item["link_"];
if (!$entry_link) {
$entry_link = $item["link"];
}
}
示例9: _parse_date
/**
* Try to read the date and return as timestamp
*
* @param string $datestr
* @return int the date
*/
function _parse_date($datestr)
{
//$datestr = preg_replace("/^\s*([0-9]{1,2})[\/\. -]+([0-9]{1,2})[\/\. -]+([0-9]{2,4})/", "\\2/\\1/\\3", $datestr);
// $datestr = str_replace('/', '-', $datestr);
if (is_numeric($datestr)) {
return $datestr;
}
$date = strtotime($datestr);
if ($date == -1) {
$date = parse_w3cdtf($datestr);
}
if ($date == -1 || $date == "") {
$date = time();
}
return $date;
}
示例10: date
$dccreator = $row['dccreator'];
$dcdate = $row['dcdate'];
$dcsubject = $row['dcsubject'];
print '<div class="item">';
print '<div class="header">';
print "<a class=\"headline\" href=\"{$item_link}\">{$item_title}</a> ";
print "<a class=\"feed\" href=\"{$feed_link}\" title=\"{$feed_description}\">{$feed_title}</a>";
print '<span class="meta">';
if ($dccreator) {
print "by {$dccreator} ";
}
if ($dcsubject) {
print "on {$dcsubject} ";
}
if ($dcdate) {
$dcdate = date("F j, Y, g:i a", parse_w3cdtf($dcdate) + $asec - FOF_TIME_OFFSET * 60 * 60);
print "at {$dcdate} ";
}
print "(cached at {$timestamp})</span>";
if (!$noedit) {
echo ' <span class="controls">';
print "<a href=\"javascript:flag_upto('c{$item_id}')\">flag all up to this item</a> ";
print "<input type=\"checkbox\" name=\"c{$item_id}\" value=\"checked\" />";
echo '</span>';
}
print "<div class=\"clearer\"></div><br/></div><div class=\"body\">{$item_content}</div></div>";
}
if (!$items) {
echo "No items found.";
}
if (!$noedit) {
示例11: strtotime
//gestion de la date de publication, selon le flux, elle se trouve parsee ? des endroits differents
if ($item['pubdate']) {
$aso_page['datestamp'] = strtotime($item['pubdate']);
} elseif ($item['dc']['date']) {
//en php5 on peut convertir les formats de dates exotiques plus facilement
if (PHP_VERSION >= 5) {
$aso_page['datestamp'] = strtotime($item['dc']['date']);
} else {
$aso_page['datestamp'] = parse_w3cdtf($item['dc']['date']);
}
} elseif ($item['issued']) {
//en php5 on peut convertir les formats de dates exotiques plus facilement
if (PHP_VERSION >= 5) {
$aso_page['datestamp'] = strtotime($item['issued']);
} else {
$aso_page['datestamp'] = parse_w3cdtf($item['issued']);
}
} else {
$aso_page['datestamp'] = time();
}
if ($formatdate != '') {
switch ($formatdate) {
case 'jm':
$aso_page['date'] = strftime('%d.%m', $aso_page['datestamp']);
break;
case 'jma':
$aso_page['date'] = strftime('%d.%m.%Y', $aso_page['datestamp']);
break;
case 'jmh':
$aso_page['date'] = strftime('%d.%m %H:%M', $aso_page['datestamp']);
break;
示例12: get_feed_item_date
function get_feed_item_date($item)
{
//Is there an Atom date? If so, parse it.
if (isset($item['issued']) && ($atom_date = $item['issued'])) {
$date = parse_w3cdtf($atom_date);
} elseif (isset($item['pubdate']) && ($rss_2_date = $item['pubdate'])) {
$date = strtotime($rss_2_date);
} elseif (isset($item['dc']['date']) && ($rss_1_date = $item['dc']['date'])) {
$date = parse_w3cdtf($rss_1_date);
} else {
$date = null;
}
//Return a UNIX timestamp.
if ($date) {
return $date;
} else {
return 0;
}
}
示例13: update
//.........这里部分代码省略.........
// Now let plugins modify the description
$description = rss_plugin_hook('rss.plugins.import.description', $description);
// link
if (array_key_exists('link', $item) && $item['link'] != "") {
$url = $item['link'];
} elseif (array_key_exists('guid', $item) && $item['guid'] != "") {
$url = $item['guid'];
} elseif (array_key_exists('link_', $item) && $item['link_'] != "") {
$url = $item['link_'];
} else {
// fall back to something basic
$url = md5($title);
}
// make sure the url is properly escaped
$url = htmlentities($url, ENT_QUOTES);
$url = rss_real_escape_string($url);
// author
if (array_key_exists('dc', $item) && array_key_exists('creator', $item['dc'])) {
// RSS 1.0
$author = $item['dc']['creator'];
} else {
if (array_key_exists('author_name', $item)) {
// Atom 0.3
$author = $item['author_name'];
} else {
$author = "";
}
}
$author = trim(strip_tags($author));
// pubdate
$cDate = -1;
if (array_key_exists('dc', $item) && array_key_exists('date', $item['dc'])) {
// RSS 1.0
$cDate = parse_w3cdtf($item['dc']['date']);
} elseif (array_key_exists('pubdate', $item)) {
// RSS 2.0 (?)
// We use the second param of strtotime here as a workaround
// of a PHP bug with strtotime. If the pubdate field doesn't
// contain seconds, the strtotime function will use the current
// time to fill in seconds in PHP4. This interferes with the
// update mechanism of gregarius. See ticket #328 for the full
// gory details. Giving a known date as a second param to
// strtotime fixes this problem, hence the 0 here.
$cDate = strtotime($item['pubdate'], 0);
} elseif (array_key_exists('published', $item)) {
// atom 1.0
$cDate = parse_iso8601($item['published']);
} elseif (array_key_exists('issued', $item)) {
//Atom, alternative
$cDate = parse_iso8601($item['issued']);
} elseif (array_key_exists('updated', $item)) {
//Atom, alternative
$cDate = parse_iso8601($item['updated']);
} elseif (array_key_exists('created', $item)) {
// atom 0.3
$cDate = parse_iso8601($item['created']);
}
// enclosure
if (array_key_exists('enclosure@url', $item)) {
$enclosure = $item['enclosure@url'];
// If the enclosure is an image, append it to the content
// but only if it isn't there yet
if ($enclosure && array_key_exists('enclosure@type', $item) && preg_match('#image/(png|gif|jpe?g)#', $item['enclosure@type']) && FALSE == strpos($description, $enclosure)) {
$description = '<img src="' . $enclosure . '" alt="" />' . $description;
$enclosure = '';
}
示例14: normalize
function normalize()
{
// if atom populate rss fields and normalize 0.3 and 1.0 feeds
if ($this->is_atom()) {
// Atom 1.0 elements <=> Atom 0.3 elements (Thanks, o brilliant wordsmiths of the Atom 1.0 standard!)
if ($this->feed_version < 1.0) {
$this->normalize_element($this->channel, 'tagline', $this->channel, 'subtitle');
$this->normalize_element($this->channel, 'copyright', $this->channel, 'rights');
$this->normalize_element($this->channel, 'modified', $this->channel, 'updated');
} else {
$this->normalize_element($this->channel, 'subtitle', $this->channel, 'tagline');
$this->normalize_element($this->channel, 'rights', $this->channel, 'copyright');
$this->normalize_element($this->channel, 'updated', $this->channel, 'modified');
}
$this->normalize_element($this->channel, 'author', $this->channel['dc'], 'creator', 'normalize_atom_person');
$this->normalize_element($this->channel, 'contributor', $this->channel['dc'], 'contributor', 'normalize_atom_person');
// Atom elements to RSS elements
$this->normalize_element($this->channel, 'subtitle', $this->channel, 'description');
if (isset($this->channel['logo'])) {
$this->normalize_element($this->channel, 'logo', $this->image, 'url');
$this->normalize_element($this->channel, 'link', $this->image, 'link');
$this->normalize_element($this->channel, 'title', $this->image, 'title');
}
for ($i = 0; $i < count($this->items); $i++) {
$item = $this->items[$i];
// Atom 1.0 elements <=> Atom 0.3 elements
if ($this->feed_version < 1.0) {
$this->normalize_element($item, 'modified', $item, 'updated');
$this->normalize_element($item, 'issued', $item, 'published');
} else {
$this->normalize_element($item, 'updated', $item, 'modified');
$this->normalize_element($item, 'published', $item, 'issued');
}
// "If an atom:entry element does not contain
// atom:author elements, then the atom:author elements
// of the contained atom:source element are considered
// to apply. In an Atom Feed Document, the atom:author
// elements of the containing atom:feed element are
// considered to apply to the entry if there are no
// atom:author elements in the locations described
// above." <http://atompub.org/2005/08/17/draft-ietf-atompub-format-11.html#rfc.section.4.2.1>
if (!isset($item["author#"])) {
if (isset($item["source_author#"])) {
// from aggregation source
$source = $item;
$author = "source_author";
} elseif (isset($this->channel["author#"])) {
// from containing feed
$source = $this->channel;
$author = "author";
} else {
$author = null;
}
if (!is_null($author)) {
$item["author#"] = $source["{$author}#"];
for ($au = 1; $au <= $item["author#"]; $au++) {
$id_to = $this->element_id('author', $au);
$id_from = $this->element_id($author, $au);
$item[$id_to] = $source[$id_from];
foreach (array('name', 'email', 'uri', 'url') as $what) {
if (isset($source["{$id_from}_{$what}"])) {
$item["{$id_to}_{$what}"] = $source["{$id_from}_{$what}"];
}
}
}
}
}
// Atom elements to RSS elements
$this->normalize_element($item, 'author', $item['dc'], 'creator', 'normalize_atom_person');
$this->normalize_element($item, 'contributor', $item['dc'], 'contributor', 'normalize_atom_person');
$this->normalize_element($item, 'summary', $item, 'description');
$this->normalize_element($item, 'atom_content', $item['content'], 'encoded');
$this->normalize_element($item, 'link_enclosure', $item, 'enclosure', 'normalize_enclosure');
// Categories
if (isset($item['category#'])) {
// Atom 1.0 categories to dc:subject and RSS 2.0 categories
$this->normalize_element($item, 'category', $item['dc'], 'subject', 'normalize_category');
} elseif (isset($item['dc']['subject#'])) {
// dc:subject to Atom 1.0 and RSS 2.0 categories
$this->normalize_element($item['dc'], 'subject', $item, 'category', 'normalize_dc_subject');
}
// Normalized item timestamp
$atom_date = isset($item['published']) ? $item['published'] : $item['updated'];
if ($atom_date) {
$epoch = @parse_w3cdtf($atom_date);
if ($epoch and $epoch > 0) {
$item['date_timestamp'] = $epoch;
}
}
$this->items[$i] = $item;
}
} elseif ($this->is_rss()) {
// RSS elements to Atom elements
$this->normalize_element($this->channel, 'description', $this->channel, 'tagline');
// Atom 0.3
$this->normalize_element($this->channel, 'description', $this->channel, 'subtitle');
// Atom 1.0 (yay wordsmithing!)
$this->normalize_element($this->image, 'url', $this->channel, 'logo');
for ($i = 0; $i < count($this->items); $i++) {
$item = $this->items[$i];
//.........这里部分代码省略.........
示例15: update_rss_feed_real
//.........这里部分代码省略.........
}
if (!$entry_guid) {
$entry_guid = make_guid_from_title($item->get_title());
}
} else {
$entry_guid = $item["id"];
if (!$entry_guid) {
$entry_guid = $item["guid"];
}
if (!$entry_guid) {
$entry_guid = $item["link"];
}
if (!$entry_guid) {
$entry_guid = make_guid_from_title($item["title"]);
}
}
if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
_debug("update_rss_feed: guid {$entry_guid}");
}
if (!$entry_guid) {
continue;
}
$entry_timestamp = "";
if ($use_simplepie) {
$entry_timestamp = strtotime($item->get_date());
} else {
$rss_2_date = $item['pubdate'];
$rss_1_date = $item['dc']['date'];
$atom_date = $item['issued'];
if (!$atom_date) {
$atom_date = $item['updated'];
}
if ($atom_date != "") {
$entry_timestamp = parse_w3cdtf($atom_date);
}
if ($rss_1_date != "") {
$entry_timestamp = parse_w3cdtf($rss_1_date);
}
if ($rss_2_date != "") {
$entry_timestamp = strtotime($rss_2_date);
}
}
if ($entry_timestamp == "" || $entry_timestamp == -1 || !$entry_timestamp) {
$entry_timestamp = time();
$no_orig_date = 'true';
} else {
$no_orig_date = 'false';
}
$entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
_debug("update_rss_feed: date {$entry_timestamp} [{$entry_timestamp_fmt}]");
}
if ($use_simplepie) {
$entry_title = $item->get_title();
} else {
$entry_title = trim(strip_tags($item["title"]));
}
if ($use_simplepie) {
$entry_link = $item->get_link();
} else {
// strange Magpie workaround
$entry_link = $item["link_"];
if (!$entry_link) {
$entry_link = $item["link"];
}
}