本文整理汇总了PHP中Zend_Layout::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Layout::render方法的具体用法?PHP Zend_Layout::render怎么用?PHP Zend_Layout::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Layout
的用法示例。
在下文中一共展示了Zend_Layout::render方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Implementation \Extlib\Mail\Message\MessageInterface::create()
*
* @param string $template
* @return string|html
*/
public function create($template = null)
{
if (null !== $template) {
$this->setScriptName($template);
}
$this->layout->assign('content', $this->layout->getView()->render($this->getScript()));
return $this->layout->render();
}
示例2: fromTemplate
/**
* Set the e-mail's body from a template
*
* @param string $tempalte
* @param array $params
* @return Geves_Mail
*/
public function fromTemplate($template, array $params)
{
$view = new Zend_View();
$view->setScriptPath($this->_templateDir);
$view->assign($params);
if ($this->_layout) {
$this->_layout->content = $view->render($template . '.phtml');
$html = $this->_layout->render();
} else {
$html = $view->render($template . '.phtml');
}
$this->setBodyHtml($html);
$this->setBodyText(strip_tags($html));
return $this;
}
示例3: shutdown
/**
* Sends mail to recipient(s) if log entries are present. Note that both
* plaintext and HTML portions of email are handled here.
*
* @return void
*/
public function shutdown()
{
// If there are events to mail, use them as message body. Otherwise,
// there is no mail to be sent.
if (empty($this->_eventsToMail)) {
return;
}
if ($this->_subjectPrependText !== null) {
// Tack on the summary of entries per-priority to the subject
// line and set it on the Zend_Mail object.
$numEntries = $this->_getFormattedNumEntriesPerPriority();
$this->_mail->setSubject("{$this->_subjectPrependText} ({$numEntries})");
}
// Always provide events to mail as plaintext.
$this->_mail->setBodyText(implode('', $this->_eventsToMail));
// If a Zend_Layout instance is being used, set its "events"
// value to the lines formatted for use with the layout.
if ($this->_layout) {
// Set the required "messages" value for the layout. Here we
// are assuming that the layout is for use with HTML.
$this->_layout->events = implode('', $this->_layoutEventsToMail);
$this->_mail->setBodyHtml($this->_layout->render());
}
// Finally, send the mail, but re-throw any exceptions at the
// proper level of abstraction.
try {
$this->_mail->send();
} catch (Exception $e) {
throw new Zend_Log_Exception($e->getMessage(), $e->getCode());
}
}
示例4: sendEmail
public function sendEmail($template, $to, $subject, $params = array())
{
try {
$config = array('auth' => 'Login', 'port' => $this->_bootstrap_options['mail']['port'], 'ssl' => 'ssl', 'username' => $this->_bootstrap_options['mail']['username'], 'password' => $this->_bootstrap_options['mail']['password']);
$tr = new Zend_Mail_Transport_Smtp($this->_bootstrap_options['mail']['server'], $config);
Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail('UTF-8');
$layout = new Zend_Layout();
$layout->setLayoutPath($this->_bootstrap_options['mail']['layout']);
$layout->setLayout('email');
$view = $layout->getView();
$view->domain_url = $this->_bootstrap_options['site']['domainurl'];
$view = new Zend_View();
$view->params = $params;
$view->setScriptPath($this->_bootstrap_options['mail']['view_script']);
$layout->content = $view->render($template . '.phtml');
$content = $layout->render();
$mail->setBodyText(preg_replace('/<[^>]+>/', '', $content));
$mail->setBodyHtml($content);
$mail->setFrom($this->_bootstrap_options['mail']['from'], $this->_bootstrap_options['mail']['from_name']);
$mail->addTo($to);
$mail->setSubject($subject);
$mail->send();
} catch (Exception $e) {
// 这里要完善
}
return true;
}
示例5: shutdown
/**
* Sends mail to recipient(s) if log entries are present. Note that both
* plaintext and HTML portions of email are handled here.
*
* @return void
*/
public function shutdown()
{
// If there are events to mail, use them as message body. Otherwise,
// there is no mail to be sent.
if (empty($this->_eventsToMail)) {
return;
}
if ($this->_subjectPrependText !== null) {
// Tack on the summary of entries per-priority to the subject
// line and set it on the Zend_Mail object.
$numEntries = $this->_getFormattedNumEntriesPerPriority();
$this->_mail->setSubject(
"{$this->_subjectPrependText} ({$numEntries})");
}
// Always provide events to mail as plaintext.
$this->_mail->setBodyText(implode('', $this->_eventsToMail));
// If a Zend_Layout instance is being used, set its "events"
// value to the lines formatted for use with the layout.
if ($this->_layout) {
// Set the required "messages" value for the layout. Here we
// are assuming that the layout is for use with HTML.
$this->_layout->events =
implode('', $this->_layoutEventsToMail);
// If an exception occurs during rendering, convert it to a notice
// so we can avoid an exception thrown without a stack frame.
try {
$this->_mail->setBodyHtml($this->_layout->render());
} catch (Exception $e) {
trigger_error(
"exception occurred when rendering layout; " .
"unable to set html body for message; " .
"message = {$e->getMessage()}; " .
"code = {$e->getCode()}; " .
"exception class = " . get_class($e),
E_USER_NOTICE);
}
}
// Finally, send the mail. If an exception occurs, convert it into a
// warning-level message so we can avoid an exception thrown without a
// stack frame.
try {
$this->_mail->send();
} catch (Exception $e) {
trigger_error(
"unable to send log entries via email; " .
"message = {$e->getMessage()}; " .
"code = {$e->getCode()}; " .
"exception class = " . get_class($e),
E_USER_WARNING);
}
}
示例6: setViewBody
public function setViewBody($script, $params = array())
{
$layout = new Zend_Layout(array('layoutPath' => $this->_getLayoutPath()));
$layout->setLayout('email');
$view = new Zend_View();
$view->setScriptPath($this->_getViewPath() . '/email');
foreach ($params as $k => $param) {
$view->assign($k, $param);
}
$layout->content = $view->render($script . '.phtml');
//$layout->content = $msg;
$html = $layout->render();
$this->setBodyHtml($html);
}
示例7: setBodyView
public function setBodyView($script, $params = array())
{
$layout = new Zend_Layout(array('layoutPath' => APPLICATION_PATH . '/views/layouts'));
$layout->setLayout('email');
$view = new Zend_View();
$view->setScriptPath(APPLICATION_PATH . '/views/email');
foreach ($params as $key => $value) {
$view->assign($key, $value);
}
$layout->content = $view->render($script . '.phtml');
$html = $layout->render();
$this->setBodyHtml($html);
return $this;
}
示例8: __invoke
public function __invoke($message)
{
$layout = new Zend_Layout();
// Установка пути к скриптам макета:
$layout->setLayoutPath(APPLICATION_PATH . '/views/scripts/layouts');
$layout->setLayout('inner');
$view = new Zend_View();
$view->setBasePath(APPLICATION_PATH . '/views/');
$view->error_message = $message;
// установка переменных:
$layout->content = $view->render('/exeption/user.phtml');
echo $layout->render();
//echo $message;
die;
}
示例9: postDispatch
public function postDispatch()
{
$layouts = array_reverse($this->_layouts);
$mvcLayout = Zend_Layout::getMvcInstance();
$mvcContentKey = $mvcLayout->getContentKey();
$content = $this->getResponse()->getBody();
$view = $this->_cloneView();
$layout = new Zend_Layout(array('layoutPath' => $mvcLayout->getLayoutPath(), 'viewSuffix' => $mvcLayout->getViewSuffix()));
$layout->setView($view);
foreach ($layouts as $layoutName) {
$layout->setLayout($layoutName);
$layout->{$mvcContentKey} = $this->getResponse()->getBody();
$this->getResponse()->setBody($layout->render());
}
}
示例10: _buildTextBody
/**
* Build the txt part of the email using the provided scripts
*
* @return void
*/
private function _buildTextBody()
{
$viewContent = '';
if ($this->getTxtView()) {
$viewContent = $this->view->render($this->getTxtView());
if (!$this->getTxtLayout()) {
// no layout, render only the view
$this->setBodyText($viewContent);
}
}
if ($this->getTxtLayout()) {
$this->_layout->setLayout($this->getTxtLayout());
$this->_layout->setView($this->view);
// assign rendered view to the layout
$this->_layout->assign('content', $viewContent);
// render the layout
$this->setBodyText($this->_layout->render($this->getTxtLayout()));
}
}
示例11: testMinimalViewObjectWorks
public function testMinimalViewObjectWorks()
{
require_once dirname(__FILE__) . '/_files/MinimalCustomView.php';
$layout = new Zend_Layout(array('view' => new Zend_Layout_Test_MinimalCustomView(), 'ViewScriptPath' => 'some/path'));
$layout->render();
}
示例12: testLayoutWithViewBasePath
public function testLayoutWithViewBasePath()
{
$layout = new Zend_Layout(array('viewBasePath' => dirname(__FILE__) . '/_files/layouts-basepath/'));
$this->assertEquals('layout inside basePath', $layout->render());
$layout->setLayout('layout2');
$this->assertEquals('foobar-helper-output', $layout->render());
}
示例13: getMailContent
/**
* Render mail content using a view and template
*
* @param string $template
* @param array $substitutions
* @param array $placeholders
* @param string $mode
* @param string $layout
* @param string $layoutPath
*/
public function getMailContent($template, $substitutions, $placeholders = array(), $mode = 'html', $layout = null, $layoutPath = null)
{
// Create the return variable
$return = '';
// Create a view renderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$view = clone $viewRenderer->view;
// Create a layout object and set it to app_path/emails/layouts
if ($layoutPath === null || $layoutPath == '') {
$layoutPath = PUBLIC_PATH . $view->templateUrl('') . 'email' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
}
// Create the layout object
$layoutObject = new Zend_Layout($layoutPath);
// Add the script path to the view that overrules the default path
$application = $this->getFrontController()->getParam('application');
$module = $this->getRequest()->getModuleName();
$scriptPath = $view->layout()->getViewScriptPath() . '/views/' . $application . '/modules/' . $module . '/';
if (!in_array($scriptPath, $view->getScriptPaths())) {
$view->addScriptPath($scriptPath);
}
// Add the default email folder for the layout/template
$view->addScriptPath(PUBLIC_PATH . $view->templateUrl('') . 'email' . DIRECTORY_SEPARATOR . 'views');
// Assign all substitutions (e.g. view variables) to the view view
foreach ($substitutions as $key => $sub) {
$view->{$key} = $sub;
}
// Replace all placeholders
if (is_array($placeholders)) {
foreach ($placeholders as $key => $sub) {
}
}
// Set the view object to the layout object
$layoutObject->setView($view);
// Initialize a default layout
if ($layout === null || $layout == '') {
$layout = 'default';
}
switch ($mode) {
case 'html':
// Render html version of template & assign to $return
$layoutObject->content = $view->render($template . '.html.phtml');
// Set the layout
$layoutObject->setLayout('' . $layout . '.html');
// Render the layout output
$return = $layoutObject->render();
// Assimilate the stylesheet in the html
$stylesheet = $layoutPath . $layout . '.css';
if (file_exists($stylesheet)) {
$stylesheetContent = file_get_contents($stylesheet);
$test = new CSSToInlineStyles($return, $stylesheetContent);
$return = $test->convert(true);
}
break;
case 'text':
// Render text version of template & assign to $return
$layoutObject->content = $view->render($template . '.text.phtml');
// Set the layout
$layoutObject->setLayout('' . $layout . '.text');
// Render the layout output
$return = $layoutObject->render();
break;
}
// Replace the placeholders in the content
$return = $this->_replacePlaceholders($return, $placeholders);
// all done, return output
return $return;
}
示例14: testRenderWithCustomInflection
public function testRenderWithCustomInflection()
{
$layout = new Zend_Layout();
$view = new Zend_View();
$layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts')
->setView($view);
$inflector = $layout->getInflector();
$inflector->setTarget('test/:script.:suffix')
->setStaticRule('suffix', 'php');
$layout->message = 'Rendered layout';
$received = $layout->render();
$this->assertContains('Testing layouts with custom inflection:', $received);
$this->assertContains($layout->message, $received);
}