15 private $_clientParams;
17 public $layout =
'//layouts/gportal';
18 public $mailLayout =
'//layouts/mail';
20 protected function beforeAction($action) {
21 $this->layout = Yii::app()->getModule(
'settings')->layoutForBackend;
22 return parent::beforeAction($action);
34 $this->_clientParams =
new stdClass;
35 $this->_clientParams->username = Yii::app()->params[
'client'][
'username'];
36 $this->_clientParams->contentPath = Yii::app()->params[
'storageFolder'] . DIRECTORY_SEPARATOR . $this->_clientParams->username;
37 return $this->_clientParams;
51 if (is_null($this->_assetsPath)) {
52 $assetsPath = ($this->module !== null) ? $this->module->name .
'/assets' : Yii::app()->controller->client->contentPath;
53 if (($assetsPath = realpath($assetsPath)) ===
false || !is_dir($assetsPath) || !is_writable($assetsPath)) {
55 Yii::t(
'yii',
'CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.', array(
'{path}' => $assetsPath))
58 $this->_assetsPath = Yii::app()->assetManager->publish($assetsPath,
false, -1,
false);
60 return $this->_assetsPath;
74 if (isset(Yii::app()->params[
'customViews']) && Yii::app()->params[
'customViews'] ==
true) {
75 $customSection = realpath(Yii::getPathOfAlias(
'site.custom'));
76 $commonSection = realpath(Yii::getPathOfAlias(
'site.common'));
77 $frontendSection = realpath(Yii::getPathOfAlias(
'site.frontend'));
78 $customView = str_replace(array($commonSection, $frontendSection), $customSection, $viewFile);
79 if (file_exists($customView)) {
87 function getJs($path){
88 echo
"<script src=".$path.
"></script>";
91 public function renderMail($view, $title = null, $data)
93 $pathToView = Yii::getPathOfAlias($view);
95 preg_match(
"/\\\\modules\\\\(?P<module_id>\w+)\\\\/", $pathToView, $matches);
97 $module = $matches[
'module_id'];
98 $module = Yii::app()->getModule($module);
99 $this->mailLayout = isset($module->mainMailTemplate)?$module->mainMailTemplate:$this->mailLayout;
101 $output = $this->renderPartial($view, $data,
true);
102 if (($layoutFile = $this->getLayoutFile($this->mailLayout)) !==
false)
103 $output = $this->renderFile($layoutFile, array(
'content' => $output,
'title' => $title),
true);
107 public function redirect($url,$terminate=
true,$statusCode=302)
110 $exceptModules = array(
'user');
111 $moduleId = isset(Yii::app()->controller->module->id)?Yii::app()->controller->module->id:
false;
112 if(!$moduleId || ($moduleId && !in_array($moduleId, $exceptModules))){
114 $url = http_build_url(
'', parse_url($url));
116 parent::redirect($url, $terminate, $statusCode);