Пример #1
0
 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;
 }
Пример #2
0
 /**
  * Allows loading view from dressing.views when application, theme and module views are unavailable.
  *
  * @param string $viewName
  * @param string $viewPath
  * @param string $basePath
  * @param null $moduleViewPath
  * @return mixed
  */
 public function resolveViewFile($viewName, $viewPath, $basePath, $moduleViewPath = null)
 {
     $viewFile = parent::resolveViewFile($viewName, $viewPath, $basePath, $moduleViewPath);
     if ($viewFile) {
         return $viewFile;
     }
     // if not found in app, try to find in dressing.views
     $path = Yii::getPathOfAlias('dressing.views');
     $appViewPath = Yii::app()->getViewPath();
     $viewPath = $path . str_replace($appViewPath, '', $viewPath);
     $basePath = $path . str_replace($appViewPath, '', $basePath);
     return parent::resolveViewFile($viewName, $viewPath, $basePath, null);
 }
Пример #3
0
 /**
  * Finds the layout file for the specified controller's layout.
  * @param CController $controller the controller
  * @param string $layoutName the layout name
  * @return string the layout file path. False if the file does not exist.
  */
 public function getLayoutFile($controller, $layoutName)
 {
     $moduleViewPath = $basePath = $this->getViewPath();
     $module = $controller->getModule();
     if (empty($layoutName)) {
         while ($module !== null) {
             if ($module->layout === false) {
                 return false;
             }
             if (!empty($module->layout)) {
                 break;
             }
             $module = $module->getParentModule();
         }
         if ($module === null) {
             $layoutName = Yii::app()->layout;
         } else {
             $layoutName = $module->layout;
             $moduleViewPath .= '/' . $module->getId();
         }
     } else {
         if ($module !== null) {
             $moduleViewPath .= '/' . $module->getId();
         }
     }
     return $controller->resolveViewFile($layoutName, $moduleViewPath . '/layouts', $basePath, $moduleViewPath);
 }
 /**
  * @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;
 }