function upload_article_handler(&$request, &$session, &$files) {
	$publication = Input::Get('Pub', 'int', 0);
	$issue = Input::Get('Issue', 'int', 0);
	$section = Input::Get('Section', 'int', 0);
	$language = Input::Get('Language', 'int', 0);
	$sLanguage = Input::Get('sLanguage', 'int', 0);
	$articleNumber = Input::Get('Article', 'int', 0);

	if (!Input::IsValid()) {
		echo "Input Error: Missing input";
		return;
	}

	// Unzip the sxw file to get the content.
	$zip = zip_open($files["filename"]["tmp_name"]);
	if ($zip) {
		$xml = null;
		while ($zip_entry = zip_read($zip)) {
			if (zip_entry_name($zip_entry) == "content.xml") {
		       	if (zip_entry_open($zip, $zip_entry, "r")) {
		           	$xml = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
			        zip_entry_close($zip_entry);
		       	}
			}
		}
		zip_close($zip);

		if (!is_null($xml)) {
			// Write the XML to a file because the XSLT functions
			// require it to be in a file in order to be processed.
			$tmpXmlFilename = tempnam("/tmp", "ArticleImportXml");
			$tmpXmlFile = fopen($tmpXmlFilename, "w");
			fwrite($tmpXmlFile, $xml);
			fclose($tmpXmlFile);

			// Transform the OpenOffice document to DocBook format.
			$xsltProcessor = xslt_create();
			$docbookXml = xslt_process($xsltProcessor,
									   $tmpXmlFilename,
									   "sxwToDocbook.xsl");
			unlink($tmpXmlFilename);

			// Parse the docbook to get the data.
			$docBookParser = new DocBookParser();
			$docBookParser->parseString($docbookXml, true);

			$article = new Article($articleNumber, $language);
			$article->setTitle($docBookParser->getTitle());
			$article->setIntro($docBookParser->getIntro());
			$article->setBody($docBookParser->getBody());

			// Go back to the "Edit Article" page.
			header("Location: /$ADMIN/articles/edit.php?Pub=$publication&Issue=$issue&Section=$section&Article=$articleNumber&Language=$language&sLanguage=$sLanguage");
		} // if (!is_null($xml))
	} // if ($zip)

	// Some sort of error occurred - show the upload page again.
	include("index.php");
} // fn upload_article_handler
 /**
  * Get Article
  *
  * @param   var Id eighter a messageId or an articleId
  * @return  peer.news.Article
  * @throws  io.IOException in case article could not be retrieved
  */
 public function getArticle($id = NULL)
 {
     $status = $this->_sendcmd('ARTICLE', $id);
     if (!NntpReply::isPositiveCompletion($status)) {
         throw new IOException('Could not get article');
     }
     with($args = explode(' ', $this->getResponse()));
     $article = new Article($args[0], $args[1]);
     // retrieve headers
     while ($line = $this->_readData()) {
         if ("\t" == $line[0] || ' ' == $line[0]) {
             $article->setHeader($header[0], $article->getHeader($header[0]) . "\n" . $line);
             continue;
         }
         $header = explode(': ', $line, 2);
         $article->setHeader($header[0], $header[1]);
     }
     // retrieve body
     while (FALSE !== ($line = $this->_readData())) {
         $body .= $line . "\n";
     }
     $article->setBody($body);
     return $article;
 }
<?php

$lib = 'path/to/doctrine2/';
require $lib . 'lib/Doctrine/ORM/Tools/Setup.php';
Setup::registerAutoloadGit($lib);
$cache = new \Doctrine\Common\Cache\ArrayCache();
$config = Setup::createAnnotationMetadataConfiguration(array(), true);
$config->setSQLLogger(new Doctrine\DBAL\Logging\EchoSQLLogger());
$connectionOptions = array('driver' => 'pdo_sqlite', 'memory' => true);
$evm = new \Doctrine\Common\EventManager();
$evm->addEventListener(array('postLoad'), new ActiveEntityListener());
$em = EntityManager::create($connectionOptions, $config, $evm);
ActiveEntityRegistry::setDefaultManager($em);
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
$schemaTool->createSchema(array($em->getClassMetadata("Article")));
$article = new Article();
$article->setHeadline("foo");
$article->setBody("barz!");
$other = Article::create(array('headline' => 'foo', 'body' => 'omg!?'));
$article->persist();
$other->persist();
$em->flush();
$em->clear();
$article = Article::find(1);
$article->remove();
$em->flush();
$articles = Article::findBy(array('headline' => 'foo'));
echo count($articles) . " articles\n";
$articles = Article::createQueryBuilder('r')->where(Article::expr()->like("r.body", '%omg%'));
echo count($articles) . " articles\n";