本文整理汇总了PHP中CController::renderInternal方法的典型用法代码示例。如果您正苦于以下问题:PHP CController::renderInternal方法的具体用法?PHP CController::renderInternal怎么用?PHP CController::renderInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CController
的用法示例。
在下文中一共展示了CController::renderInternal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendNotificationEmail
private function sendNotificationEmail($list,$user,$criteria){
$app_email_name = Yii::app()->params['app_email_name'];
$app_email = Yii::app()->params['app_email'];
$email_prefix = Yii::app()->params['email_prefix'];
$headers = "From: $app_email_name <$app_email>\r\n"; //optional header fields
$headers .= "Content-type: text/html\r\n";
ini_set('sendmail_from', $app_email);
$listurl="";
foreach ($list as $key => $value) {
$model = Dataset::model()->findByPk($value);
$url = Yii::app()->params['home_url']."/dataset/".$model->identifier;
$author_list = '';
if (count($model->authors) > 0) {
$i = 0;
foreach( $model->authors as $key => $author){
if (++$i < count($model->authors)) $author_list .= $author->name.';'; else $author_list .= $author->name.' ';
}
}
$listurl .= <<<EO_LU
<span style='font-weight:bold;'>{$model->title}</span><br>
{$author_list}<br>
<a href='{$url}'>{$url}</a><br><br>
EO_LU;
}
$recipient = Yii::app()->params['notify_email'];
$subject = "GigaDB has new content which matches your interest";
$body = CController::renderInternal(Yii::app()->basePath.'/views/search/emailMatchedSearches.php',array('listurl'=>$listurl,'criteria'=>$criteria),true);
mail($user->email, $subject, $body, $headers);
Yii::log(__FUNCTION__."> Sent email to $recipient, $subject");
}
示例2: getPlainTextVersion
public static function getPlainTextVersion($message, $params)
{
$path = Yii::getPathOfAlias(Yii::app()->mail->viewPath);
$plainViewPath = $path . DIRECTORY_SEPARATOR . $message->view . '.plain.php';
if (!file_exists($plainViewPath)) {
return strip_tags(strtr($message->getBody(), array("\t" => '', ' ' => ' ', '<br>' => "\n", '<br/>' => "\n", '<br />' => "\n", '</p>' => "\n\n")));
}
if (isset(Yii::app()->controller)) {
$controller = Yii::app()->controller;
} else {
$controller = new CController('YiiMail');
}
$body = $controller->renderInternal($plainViewPath, $params, true);
$footer = $controller->renderInternal($path . DIRECTORY_SEPARATOR . 'footer.plain.php', null, true);
return $body . PHP_EOL . PHP_EOL . $footer;
}
示例3: renderMessage
public function renderMessage($view, array $data = array())
{
$controller = new \CController('SmsSender');
$viewPath = \Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'views';
$viewFile = $controller->resolveViewFile($view, $viewPath, $viewPath);
$body = $controller->renderInternal($viewFile, $data, true);
return $body;
}
示例4: generate
public function generate()
{
$model = new MainAccountModel();
$model->save();
$ccc = new CController('context');
$fileName = tempnam(sys_get_temp_dir(), "asd");
$fileName .= ".html";
$htmlOutput = $ccc->renderInternal(Yii::getPathOfAlias("application.views.templates") . '/index.php', $model->attributes, true);
file_put_contents($fileName, $htmlOutput);
return $fileName;
}
示例5: setBody
/**
* Set the body of this entity, either as a string, or array of view
* variables if a view is set, or as an instance of
* {@link Swift_OutputByteStream}.
*
* @param mixed the body of the message. If a $this->view is set and this
* is a string, this is passed to the view as $body. If $this->view is set
* and this is an array, the array values are passed to the view like in the
* controller render() method
* @param string content type optional. For html, set to 'html/text'
* @param string charset optional
*/
public function setBody($body = '', $contentType = null, $charset = null)
{
if ($this->view !== null) {
if (!is_array($body)) {
$body = array('body' => $body);
}
// if Yii::app()->controller doesn't exist create a dummy
// controller to render the view (needed in the console app)
if (isset(Yii::app()->controller)) {
$controller = Yii::app()->controller;
} else {
$controller = new CController('YiiMail');
}
// File Path to Template
$viewPath = "";
// Name of current theme if enabled
$themeName = "";
if (Yii::app() instanceof CConsoleApplication) {
if (Yii::app()->theme && Yii::app()->theme != "") {
$themeName = Yii::app()->theme;
}
} else {
// WebApplication
if (($theme = Yii::app()->getTheme()) !== null) {
$themeName = $theme->getName();
}
}
// When ThemeName is speified
if ($themeName != "") {
$viewThemed = str_replace('application.views.', 'webroot.themes.' . $themeName . '.views.', $this->view);
$viewThemed = preg_replace('/application\\.modules(?:_core)?\\.(.*?)\\.views\\.(.*)/i', 'webroot.themes.' . $themeName . '.views.\\1.\\2', $viewThemed);
if (file_exists(Yii::getPathOfAlias($viewThemed) . ".php")) {
$viewPath = Yii::getPathOfAlias($viewThemed) . ".php";
}
}
// Use orginal view name, if not set yet
if ($viewPath == "") {
$viewPath = Yii::getPathOfAlias($this->view) . ".php";
}
$body = $controller->renderInternal($viewPath, array_merge($body, array('mail' => $this)), true);
}
return $this->message->setBody($body, $contentType, $charset);
}
示例6: setBody
public function setBody($body = '', $contentType = null, $charset = null)
{
if ($this->view !== null) {
if (!is_array($body)) {
$body = array('body' => $body);
}
// if Yii::app()->controller doesn't exist create a dummy
// controller to render the view (needed in the console app)
if (isset(Yii::app()->controller)) {
$controller = Yii::app()->controller;
} else {
$controller = new CController('YiiMail');
}
// renderPartial won't work with CConsoleApplication, so use
// renderInternal - this requires that we use an actual path to the
// view rather than the usual alias
$viewPath = Yii::app()->theme->getBasePath() . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . Yii::app()->mail->viewPath . DIRECTORY_SEPARATOR . $this->view . '.php';
$body = $controller->renderInternal($viewPath, array_merge($body, array('mail' => $this)), true);
}
return $this->message->setBody($body, $contentType, $charset);
}
示例7: renderView
/**
* Render the view file
* @param string $viewName Name of the view
* @param array $viewData Data for extraction
* @return string The rendered result
* @throws CException
*/
public function renderView($viewName, $viewData = null)
{
//resolve the file name
if (($viewFile = $this->getViewFile($viewName)) !== false) {
//use controller instance if available or create dummy controller for console applications
if (isset(Yii::app()->controller)) {
$controller = Yii::app()->controller;
} else {
$controller = new CController(__CLASS__);
}
//render and return the result
return $controller->renderInternal($viewFile, $viewData, true);
} else {
//file name does not exist
throw new CException('View "' . $viewName . '" does not exist!');
}
}
示例8: _render
/**
* Render message view
* @param $view
* @param array $params
* @return string
*/
protected function _render($view, $params = array())
{
if (isset(Yii::app()->controller)) {
$controller = Yii::app()->controller;
} else {
$controller = new CController(get_class());
}
$viewPath = Yii::app()->findLocalizedFile(Yii::getPathOfAlias($this->_viewPath . '.' . $view) . '.php');
return $controller->renderInternal($viewPath, $params, true);
}
示例9: checkBox
/**
* @param $model CModel
* @param $attribute string
* @param array $htmlOptions array
* @return string
*/
public static function checkBox($model, $attribute, $htmlOptions = array())
{
return CController::renderInternal('./application/protected/components/decorators/backend/form/views/checkbox.php', array('model' => $model, 'attribute' => $attribute, 'htmlOptions' => $htmlOptions), TRUE);
}
示例10: renderBody
/**
* @param string $view
* @param string $layout
* @param array $data
*
* @return string
*/
public function renderBody($view, $layout = '//layouts/main', array $data = array())
{
$controller = new CController('SwiftMailerComponent');
$viewPath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'views';
$viewFile = $controller->resolveViewFile($view, $viewPath, $viewPath);
$layoutFile = $controller->resolveViewFile($layout, $viewPath, $viewPath);
$body = $controller->renderInternal($viewFile, $data, true);
if (null !== $layout) {
$body = $controller->renderInternal($layoutFile, array('content' => $body), true);
}
return $body;
}
示例11: generateEmailForSide
/**
* generate the email text for the given side.
*
* @param CController $controller
* @param array $template_data
* @param string $side
*
* @return string
*/
protected function generateEmailForSide(CController $controller, array $template_data, $side)
{
if ($template_data['compliant']) {
$file = 'email_compliant.php';
} else {
$file = 'email_noncompliant.php';
}
$view = $this->getViewPath() . DIRECTORY_SEPARATOR . $file;
return $controller->renderInternal($view, $template_data, true);
}
示例12: renderTemplate
/**
* @return string
*/
protected function renderTemplate()
{
$controller = new \CController('message');
return $controller->renderInternal(\Yii::getPathOfAlias($this->messageTemplate) . '.php', $this->messageData, true);
}
示例13: getMailOut
/**
* Returns Mail Output for that activity
*
* @return type
*/
public function getMailOut()
{
$controller = new CController('MailX');
// Determine View
$view = 'application.modules_core.activity.views.activities.' . $this->type . "_mail";
if ($this->module != "") {
$view = 'application.modules_core.' . $this->module . '.views.activities.' . $this->type . "_mail";
$viewPath = Yii::getPathOfAlias($view) . '.php';
// Seems not exists, try 3rd party module folder
if (!file_exists($viewPath)) {
$view = 'application.modules.' . $this->module . '.views.activities.' . $this->type . "_mail";
}
}
$viewPath = Yii::getPathOfAlias($view) . '.php';
$underlyingObject = $this->getUnderlyingObject();
$workspace = null;
if ($this->content->space_id != "") {
$workspace = Space::model()->findByPk($this->content->space_id);
}
$user = $this->content->user;
if ($user == null) {
return;
}
return $controller->renderInternal($viewPath, array('activity' => $this, 'wallEntryId' => 0, 'user' => $user, 'target' => $underlyingObject, 'workspace' => $workspace), true);
}
示例14: setBody
/**
* Set the body of this entity, either as a string, or array of view
* variables if a view is set, or as an instance of
* {@link Swift_OutputByteStream}.
*
* @param mixed the body of the message. If a $this->view is set and this
* is a string, this is passed to the view as $body. If $this->view is set
* and this is an array, the array values are passed to the view like in the
* controller render() method
* @param string content type optional. For html, set to 'html/text'
* @param string charset optional
*/
public function setBody($body = '', $contentType = null, $charset = null)
{
if ($this->view !== null) {
if (!is_array($body)) {
$body = array('body' => $body);
}
// if Yii::app()->controller doesn't exist create a dummy
// controller to render the view (needed in the console app)
if (isset(Yii::app()->controller)) {
$controller = Yii::app()->controller;
} else {
$controller = new CController('YiiMail');
}
// renderPartial won't work with CConsoleApplication, so use
// renderInternal - this requires that we use an actual path to the
// view rather than the usual alias
//Поменял Yii::app()->mail на Yii::app()->mailer, т.к. уже есть модуль mail
$viewPath = Yii::getPathOfAlias(Yii::app()->mailer->viewPath . '.' . $this->view) . '.php';
$body = $controller->renderInternal($viewPath, array_merge($body, array('mail' => $this)), true);
}
return $this->message->setBody($body, $contentType, $charset);
}
示例15: render
/**
* Render a view file and return result
*
* If $controller is not set, the (localized) view file is searched in $viewPath
* and the layout in $layoutFile is applied, if set.
*
* @param string $view name of view to render
* @param array $data view data
* @return string rendered content
*/
private function render($view, $data = array())
{
if (($controller = $this->controller) === null) {
static $controller;
if ($controller === null) {
$controller = new CController('pdffile');
}
$controller->layout = $this->layout;
// Required to make console app play nicely during rendering
Yii::app()->attachBehavior('consoleWorkaround', array('class' => 'ConsoleAppWorkaround', '_viewPath' => $this->baseViewPath, '_layoutPath' => $this->layoutPath));
$file = Yii::app()->findLocalizedFile($this->viewPath . '/' . $view . '.php');
if ($file === false) {
throw new CException('Could not find view file ' . $view);
}
ini_set('implicit_flush', false);
$content = $controller->renderInternal($file, $data, true);
if ($controller->layout === null) {
return $content;
}
return $controller->renderInternal($controller->getLayoutFile($controller->layout), array('content' => $content), true);
} else {
return $controller->render($view, $data, true);
}
}