/** * @param EcrProjectUpdateserverRelease $release * * @throws DomainException * @return \EcrProjectUpdateserver */ public function addRelease(EcrProjectUpdateserverRelease $release) { $base = ECRPATH_UPDATESERVER . '/' . $this->project->comName; //-- Update the feed.xml $item = new EcrProjectFeedItem(); $title = JFile::stripExt(JFile::getName($release->downloads[0])); $item->title = $title; $item->link = $release->downloads[0]; $item->id = $release->downloads[0]; $item->summary = $release->description; $item->summary = '<br /><b>Downloads</b>'; foreach ($release->downloads as $download) { $item->summary .= '<br /><a href="' . $download . '">' . JFile::getName($download) . '</a>'; } $item->content = $item->summary; $path = $base . '/' . $release->state . '-feed.xml'; $feed = new EcrProjectFeed($path); $feed->addItem($item); $buffer = $feed->printPretty(); JFile::write($path, $buffer); //-- Update the update.xml $fileName = 'release' == $release->state ? 'extension.xml' : $release->state . '.xml'; $path = $base . '/' . $fileName; if (false == JFile::exists($path)) { throw new DomainException(sprintf('%s - File not found: %s', __METHOD__, $path)); } $xml = EcrProjectHelper::getXML($path); $updateElement = $xml->addChild('update'); $updateElement->addChild('name', $this->project->name); $updateElement->addChild('description', $this->project->description); $updateElement->addChild('element', $this->project->comName); $updateElement->addChild('type', $this->project->type); $updateElement->addChild('version', $this->project->version); $updateElement->addChild('infourl', $this->project->authorUrl); //-- Unsupported :( $updateElement->addChild('releasedate', date('d-M-Y')); $downloadsElement = $updateElement->addChild('downloads'); foreach ($release->downloads as $download) { $d = $downloadsElement->addChild('downloadurl', $download); $d->addAttribute('type', 'full'); $d->addAttribute('format', JFile::getExt($download)); } $tagsElement = $updateElement->addChild('tags', $this->project->name); $tagsElement->addChild('tag', $release->state); $updateElement->addChild('maintainer', $this->project->author); $updateElement->addChild('maintainerurl', $this->project->authorUrl); $targetElement = $updateElement->addChild('targetplatform'); $targetElement->addAttribute('name', 'joomla'); $targetElement->addAttribute('version', $this->project->JCompat); $buffer = $xml->asFormattedXML(); JFile::write($path, $buffer); $this->updateExtensionIndex(); return $this; }
<?php /** * User: elkuku * Date: 08.06.12 * Time: 10:14 */ echo date(DATE_ATOM); $u = new EcrProjectUpdateserver($this->project); $u->create($this->project); echo '<pre>'; $f = new EcrProjectFeed(); $f->title = 'Der erste Feed'; $f->link = 'http://qqq'; $f->description = 'Die erste Beschreibung'; $i = new EcrProjectFeedItem(); $i->title = 'Item titel'; $i->description = 'Item Besxchreibung'; $i->link = 'http://yyyy'; $f->addItem($i); echo htmlentities($f); echo "\n\n"; echo htmlentities($f->printPretty()); echo '</pre>';