Beispiel #1
1
 /**
  * If we are acting in the module context and the layout is empty we only should renderPartial the content.
  *
  * @param string $view   The name of the view file (e.g. index)
  * @param array  $params The params to assign into the value for key is the variable and value the content.
  *
  * @return string
  */
 public function render($view, $params = [])
 {
     if (!empty($this->module->context) && empty($this->layout)) {
         return $this->renderPartial($view, $params);
     }
     return parent::render($view, $params);
 }
 /**
  * Modified render method to display the view. This takes in the view id as a parameter instead of
  * view name.
  *
  * @param int   $view the view identifier as set in one of Module::VIEW constants
  * @param array $params the parameters (name-value pairs) that should be made available in the view.
  * These parameters will not be available in the layout.
  *
  * @return string the rendering result
  */
 public function display($view, $params = [])
 {
     if (!empty($this->_module->getLayout($view))) {
         $this->layout = $this->_module->getLayout($view);
     }
     $view = $this->fetchView($view);
     return parent::render($view, $params);
 }
 public function render($view, $params = [])
 {
     if (Yii::$app->request->isAjax) {
         return $this->renderAjax($view, $params);
     } else {
         return parent::render($view, $params);
     }
 }
Beispiel #4
0
 public function render($view, $data = NULL, $return = false)
 {
     if (isset($_POST['minimal'])) {
         echo \yii\helpers\Json::encode(parent::renderPartial($view, $data, true));
     } else {
         return parent::render($view, $data, $return);
     }
 }
 /**
  * Автоматический renderPartial, если ajax-запрос.
  */
 public function render($view, $params = [], $returnContent = false)
 {
     if (Yii::$app->request->isAjax) {
         return parent::renderPartial($view, $params, $returnContent);
     } else {
         return parent::render($view, $params, $returnContent);
     }
 }
Beispiel #6
0
 public function render($params = [], $view = '')
 {
     if ($view == '') {
         $view = \Yii::$app->controller->action->id;
     }
     $view = $view . ".html";
     $arr = array_merge($params, $this->assign);
     return parent::render($view, $arr);
 }
Beispiel #7
0
 public function render($view, $params = [])
 {
     $position = $this->module->positionMenu;
     if (in_array($position, ['left', 'top', 'right'])) {
         return parent::render("/layouts/{$position}-menu", ['view' => $view, 'params' => $params]);
     } else {
         return parent::render($view, $params);
     }
 }
 public function render($view = null, $params = [])
 {
     if (is_array($view)) {
         $params = $view;
         $view = null;
     }
     if ($view === null) {
         $view = $this->action->id;
     }
     return parent::render($view, $params);
 }
Beispiel #9
0
 public function render($view, $params = [])
 {
     $ua_arr = ['ua' => (object) $this->getua()];
     $urlParams = ['urlParams' => (object) Yii::$app->request->getQueryParams()];
     $tpldata = array_merge($params, $urlParams, $ua_arr);
     $tpldata['APP_CODE'] = @\Yii::$app->params['app_code'];
     Yii::$app->view->params['tpldata'] = (object) $tpldata;
     $params['tplData'] = $tpldata;
     Yii::$app->response->formatters[Response::FORMAT_HTML] = 'mysoft\\web\\MyHtmlResponseFormatter';
     return parent::render($view, $params);
 }
 public function render($view, $params = [])
 {
     $devicedetect = \Yii::$app->devicedetect;
     $isMobile = $devicedetect->isMobile();
     $isTablet = $devicedetect->isTablet();
     $mobileTpl = $isMobile && !$isTablet;
     // detect and change layout
     if ($mobileTpl) {
         $this->layout = '@app/views/layouts/sp_main';
     }
     // detect and render view
     $detectView = $view . ($mobileTpl ? '_sp' : '');
     $detectPath = parent::getViewPath() . "/{$detectView}.php";
     return parent::render(file_exists($detectPath) ? $detectView : $view, $params);
 }
Beispiel #11
0
 /**
  * @param string $view
  * @param array $params
  * @return string
  */
 public function render($view, $params = [])
 {
     if (!$this->beforeRender || $this->module instanceof Application) {
         return parent::render($view, $params);
     }
     try {
         $viewApp = $this->beforeRender . $this->module->id . '/' . $this->id . '/' . $view;
         return parent::render($viewApp, $params);
     } catch (InvalidParamException $e) {
         \Yii::error($e->getMessage());
         try {
             return parent::render($view, $params);
         } catch (InvalidParamException $e) {
             return $this->output($e->getMessage());
         }
     }
 }
Beispiel #12
0
 /**
  * @param string $view
  * @param array $params
  * @return string
  */
 public function render($view, $params = [])
 {
     if ($this->module instanceof Application) {
         return parent::render($view, $params);
     }
     if (strpos($view, '/') && !strpos($view, '@app/views')) {
         return parent::render($view, $params);
     }
     $viewDir = "@app/views/modules/" . $this->module->id . '/' . $this->id;
     $viewApp = $viewDir . '/' . $view;
     if (isset(\Yii::$app->view->theme->pathMap['@app/views'])) {
         $tmpPaths = [];
         foreach (\Yii::$app->view->theme->pathMap['@app/views'] as $path) {
             $tmpPaths[] = $path . "/modules/" . $this->module->id . '/' . $this->id;
         }
         $tmpPaths[] = $this->viewPath;
         \Yii::$app->view->theme->pathMap = ArrayHelper::merge(\Yii::$app->view->theme->pathMap, [$viewDir => $tmpPaths]);
     }
     return parent::render($viewApp, $params);
 }
 public function render($view, $params = [])
 {
     $this->beforeRender($params);
     return parent::render($view, $params);
 }
 public function render($view, $params = [])
 {
     \worstinme\forum\assets\Asset::register($this->view);
     return parent::render($view, $params);
 }
Beispiel #15
0
 /**
  * redefine controller render function
  * 
  * @see \yii\base\Controller::render()
  */
 public function render($view, $params = [])
 {
     $content = parent::render($view, $params);
     return $this->compressHtml($content);
 }
Beispiel #16
0
 /**
  * Вызов возможен как render($view, $params)
  * или как render($params)
  * тогда $view = название функции action
  * например если вызов произошел из метода actionOrders то $view = 'orders'
  *
  * @param string|array $view   шаблон или параметры шаблона
  * @param array        $params параметры шаблона если $view = шаблон, иначе не должен указываться
  *
  * @return string = \yii\base\Controller::render()
  */
 public function render($view = '', $params = [])
 {
     if (is_array($view)) {
         $params = $view;
         $view = strtolower(str_replace('action', '', debug_backtrace(2)[1]['function']));
     } else {
         if ($view == '') {
             $params = [];
             $view = strtolower(str_replace('action', '', debug_backtrace(2)[1]['function']));
         } else {
             if ($view == '.tpl') {
                 $view = strtolower(str_replace('action', '', debug_backtrace(2)[1]['function'])) . '.tpl';
             }
         }
     }
     if (StringHelper::endsWith(strtolower($view), '.tpl')) {
         $this->layout .= '.tpl';
     }
     if (self::getParam('_view', '') != '') {
         \cs\services\VarDumper::dump($params, 10);
         return '';
     }
     return parent::render($view, $params);
 }