hash = md5(openssl_random_pseudo_bytes(5)); $this->_struct = ' { "origin" : {"type":"string", "size":64, "mandatory":true, "key":true }, "node" : {"type":"string", "size":96, "mandatory":true, "key":true }, "nodeid" : {"type":"string", "size":96, "mandatory":true, "key":true }, "aname" : {"type":"string", "size":128 }, "aid" : {"type":"string", "size":128 }, "aemail" : {"type":"string", "size":64 }, "title" : {"type":"text" }, "content" : {"type":"text" }, "contentcleaned" : {"type":"text" }, "commentplace" : {"type":"string", "size":128 }, "published" : {"type":"date" }, "updated" : {"type":"date" }, "delay" : {"type":"date" }, "lat" : {"type":"string", "size":128 }, "lon" : {"type":"string", "size":128 }, "links" : {"type":"text" }, "picture" : {"type":"int", "size":4 }, "tags" : {"type":"text" }, "hash" : {"type":"string", "size":128 } }'; parent::__construct(); } private function getContent($contents) { $content = ''; foreach($contents as $c) { switch($c->attributes()->type) { case 'html': case 'xhtml': return (string)$c->asXML(); break; case 'text': default : $content = (string)$c; break; } } return $content; } public function set($item, $from, $delay = false, $node = false) { if($item->item) $entry = $item->item; else $entry = $item; $this->origin = $from; if($node) $this->node = $node; else $this->node = (string)$item->attributes()->node; $this->nodeid = (string)$entry->attributes()->id; if($entry->entry->id) $this->nodeid = (string)$entry->entry->id; // Get some informations on the author if($entry->entry->author->name) $this->aname = (string)$entry->entry->author->name; if($entry->entry->author->uri) $this->aid = substr((string)$entry->entry->author->uri, 5); if($entry->entry->author->email) $this->aemail = (string)$entry->entry->author->email; // Non standard support if($entry->entry->source && $entry->entry->source->author->name) $this->aname = (string)$entry->entry->source->author->name; if($entry->entry->source && $entry->entry->source->author->uri) $this->aid = substr((string)$entry->entry->source->author->uri, 5); $this->title = (string)$entry->entry->title; // Content if($entry->entry->summary && (string)$entry->entry->summary != '') $summary = '
'.(string)$entry->entry->summary.'
'; else $summary = ''; if($entry->entry && $entry->entry->content) { $content = $this->getContent($entry->entry->content); } elseif($summary == '') $content = __(''); else $content = ''; $content = $summary.$content; if($entry->entry->updated) $this->updated = (string)$entry->entry->updated; else $this->updated = gmdate(DATE_ISO8601); if($entry->entry->published) $this->published = (string)$entry->entry->published; elseif($entry->entry->updated) $this->published = (string)$entry->entry->updated; else $this->published = gmdate(DATE_ISO8601); if($delay) $this->delay = $delay; $contentimg = $this->setAttachements($entry->entry->link); // Tags parsing if($entry->entry->category) { $this->tags = array(); if($entry->entry->category->count() == 1 && isset($entry->entry->category->attributes()->term)) array_push($this->tags, (string)$entry->entry->category->attributes()->term); else foreach($entry->entry->category as $cat) array_push($this->tags, (string)$cat->attributes()->term); } if(!empty($this->tags)) $this->tags = serialize($this->tags); if($contentimg != '') $content .= '