Permalink
Browse files

Merge branch '2.1' of github.com:OPL/Open-Power-Template into 2.1

  • Loading branch information...
2 parents ae60548 + b1da6fd commit b8333ff9e0107cadf104045b89b33b9932675f3f @eXtreme eXtreme committed Jul 16, 2010
Showing with 57 additions and 5 deletions.
  1. +4 −4 lib/Opt/Format/RuntimeGenerator.php
  2. +51 −0 lib/Opt/Output/Exception.php
  3. +2 −1 lib/Opt/Output/Http.php
@@ -47,13 +47,13 @@ protected function _build($hookName)
$section = $this->_getVar('section');
// Choose the data source.
- if(!is_null($section['parent']))
+ if($section['parent'] !== null)
{
- $parent = Opt_Instruction_BaseSection::getSection($section['parent']);
+ $parent = Opt_Instruction_Section_Abstract::getSection($section['parent']);
$parent['format']->assign('item', $section['name']);
$ds = $parent['format']->get('section:variable');
}
- elseif(!is_null($section['datasource']))
+ elseif($section['datasource'] !== null)
{
$ds = $section['datasource'];
}
@@ -65,7 +65,7 @@ protected function _build($hookName)
if(!is_object($this->_decorated))
{
- throw new Opt_FormatNotDecorated_Exception('StaticGenerator');
+ throw new Opt_Format_Exception('StaticGenerator format must be decorated.');
}
$ref = ($this->_decorated->property('section:useReference') ? ' & ' : '');
@@ -0,0 +1,51 @@
+<?php
+/*
+ * OPEN POWER LIBS <http://www.invenzzia.org>
+ *
+ * This file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE. It is also available through
+ * WWW at this URL: <http://www.invenzzia.org/license/new-bsd>
+ *
+ * Copyright (c) Invenzzia Group <http://www.invenzzia.org>
+ * and other contributors. See website for details.
+ *
+ */
+
+/**
+ * The class for output system errors.
+ *
+ * @author Tomasz Jędrzejewski
+ * @copyright Invenzzia Group <http://www.invenzzia.org/> and contributors.
+ * @license http://www.invenzzia.org/license/new-bsd New BSD License
+ */
+class Opt_Output_Exception extends Opt_Exception
+{
+ /**
+ * The output name.
+ * @var string
+ */
+ private $_outputName;
+
+ /**
+ * Creates a new output exception. The output system should specify
+ * its name in the second argument.
+ *
+ * @param string $message The error message.
+ * @param string $output The name of the output system.
+ */
+ public function __construct($message, $output)
+ {
+ $this->message = (string)$message;
+ $this->_outputName = (string)$output;
+ } // end __construct();
+
+ /**
+ * Returns the name of the output that caused the exception.
+ *
+ * @return string
+ */
+ public function getOutputName()
+ {
+ return $this->_outputName;
+ } // end getOutputName();
+} // end Opt_Output_Exception;
@@ -167,6 +167,7 @@ public function setContentType($contentType = null, $charset = null)
if($this->_tpl->contentNegotiation)
{
// This part of the code requires OPC!
+ // TODO: Replace with non-singleton OPC
$visit = Opc_Visit::getInstance();
if($contentType == self::XHTML)
{
@@ -268,7 +269,7 @@ public function render(Opt_View $view)
}
elseif($this->_parser == 'Html' || $this->_parser == 'Xml')
{
- throw new Opt_OutputOverloaded_Exception;
+ throw new Opt_Output_Exception('The HTTP output is overloaded: an HTML or XML template has already been sent.', 'HTTP');
}
return $view->_parse($this, true);
} // end output();

0 comments on commit b8333ff

Please sign in to comment.