## Apache Zeta Components Manual :: File Source for template.php

## Source for file template.php

Documentation is available at template.php

1. <?php
2. /**
3. *
4. * Licensed to the Apache Software Foundation (ASF) under one
5. * or more contributor license agreements. See the NOTICE file
6. * distributed with this work for additional information
7. * regarding copyright ownership. The ASF licenses this file
8. * to you under the Apache License, Version 2.0 (the
9. * "License"); you may not use this file except in compliance
10. * with the License. You may obtain a copy of the License at
11. *
12. * http://www.apache.org/licenses/LICENSE-2.0
13. *
14. * Unless required by applicable law or agreed to in writing,
15. * software distributed under the License is distributed on an
16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17. * KIND, either express or implied. See the License for the
18. * specific language governing permissions and limitations
19. * under the License.
20. *
21. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
22. * @version //autogentag//
23. * @filesource
24. * @package MvcTemplateTiein
25. */
27. /**
28. * The view handler that uses the template component to render result objects.
29. *
30. * @package MvcTemplateTiein
31. * @version //autogentag//
32. * @mainclass
33. */
34. class ezcMvcTemplateViewHandler implements ezcMvcViewHandler
35. {
36. /**
37. * Contains the zone name
38. *
39. * @var string
40. */
41. protected $zoneName ;
43. /**
44. * Contains the result after process() has been called.
45. *
46. * @var mixed
47. */
48. protected $result ;
50. /**
51. * Contains the variables that will be available in the template.
52. *
53. * @var array(mixed)
54. */
55. protected $variables = array();
57. /**
58. * Creates a new view handler, where $zoneName is the name of the block and
59. * $templateLocation the location of a view template.
60. *
61. * @param string $zoneName
62. * @param string $templateLocation
63. */
64. public function __construct ( $zoneName, $templateLocation = null )
65. {
66. $this-> zoneName = $zoneName;
67. $this->templateLocation = $templateLocation;
69. $this->template = new ezcTemplate ;
70. }
72. /**
73. * Adds a variable to the template, which can then be used for rendering
74. * the view.
75. *
76. * @param string $name
77. * @param mixed $value
78. */
79. public function send ( $name, $value )
80. {
81. $this->template->send->$name = $value;
82. }
84. /**
85. * Processes the template with the variables added by the send() method.
86. * The result of this action should be retrievable through the getResult() method.
87. *
88. * @param mixed $last
89. */
90. public function process ( $last )
91. {
92. $this-> result = $this->template->process( $this->templateLocation );
93. }
95. /**
96. * Returns the name of the template, as set in the constructor.
97. *
98. * @return string
99. */
100. public function getName ()
101. {
102. return $this-> zoneName ;
103. }
105. /**
106. * Returns the result of the process() method.
107. *
108. * @return mixed
109. */
110. public function getResult ()
111. {
112. return $this-> result ;
113. }
114. }
115. ?>

Documentation generated by phpDocumentor 1.4.3