gnu-social/vendor/zetacomponents/document/docs/tutorial/02_01_link_provider.php
2021-07-16 19:44:40 +01:00

30 lines
818 B
PHP

<?php
require 'tutorial_autoload.php';
class myLinkProvider extends ezcDocumentEzXmlLinkProvider
{
public function fetchUrlById( $id, $view, $show_path )
{
return 'http://host/path/' . $id;
}
public function fetchUrlByNodeId( $id, $view, $show_path ) {}
public function fetchUrlByObjectId( $id, $view, $show_path ) {}
}
$document = new ezcDocumentEzXml();
$document->loadString( '<?xml version="1.0"?>
<section xmlns="http://ez.no/namespaces/ezpublish3">
<header>Paragraph</header>
<paragraph>Some content, with a <link url_id="1">link</link>.</paragraph>
</section>' );
// Set link provider
$converter = new ezcDocumentEzXmlToDocbookConverter();
$converter->options->linkProvider = new myLinkProvider();
$docbook = $converter->convert( $document );
echo $docbook->save();
?>