lib/controllers/recipe.php:
<?php
class onrRecipeController extends ezcMvcController
{
public function doView()
{
$id = (int) $this->id;
$res = new ezcMvcResult;
$d = ezcDbInstance::get();
$q = $d->createSelectQuery();
$q->select( '*' )
->from( 'recipe' )
->where( $q->expr->eq( 'id', $q->bindValue( $id ) ) );
$s = $q->prepare();
$s->execute();
$data = $s->fetchAll();
if ( empty ( $data ) )
{
$res->status = new ezcMvcExternalRedirect( '/' );
return $res;
}
// render rest recipe as HTML
$desc = $data[0]['description'];
$document = new ezcDocumentRst();
$document->loadString( $desc );
$document->options->xhtmlVisitor = 'ezcDocumentRstXhtmlBodyVisitor';
$xhtml = $document->getAsXhtml();
$xml = $xhtml->save();
$data[0]['description'] = $xml;
$res->variables['data'] = $data[0];
return $res;
}
}
?>