35 $this->redirect(Yii::app()->createUrl(Yii::app()->getModule(
'user')->homePageUrl));
48 if (Yii::app()->request->getParam(
'path',
false)) {
49 $path =
'/' . Yii::app()->request->getParam(
'path',
'');
51 $content = $this->_getContentSource()->getContent($path);
53 if ($content->hasAccess(Yii::app()->user)) {
54 $fileContent = file_get_contents($content->getFile());
67 $this->_noAccess($content);
71 throw new Exception(
'Path not exists: ' . $this->_getContentSource()->contentSource->contentFile($path));
73 throw new CHttpException(404);
89 if (Yii::app()->request->getParam(
'path',
false)) {
90 $path =
'/' . Yii::app()->request->getParam(
'path',
'');
92 $content = $this->_getContentSource()->getContent($path);
96 if ($content->hasAccess(Yii::app()->user)) {
97 $content = $this->renderFile($content->getFile(), null,
true);
98 echo $this->processOutput($content);
100 $this->_noAccess($content);
104 throw new Exception(
'Path not exists: ' . $this->_getContentSource()->contentSource->contentFile($path));
106 throw new CHttpException(404);
121 throw new CHttpException(404);
124 $folder = Yii::app()->request->getParam(
'folder',
'').
'/';
125 $startPage = $this->module->getContentSource()->getStartPage($folder, substr(Yii::app()->locale->id, 0, 2));
127 if($startPage ===
false) {
128 $startPage =
'/' . Yii::app()->request->getParam(
'path',
'') . $folder . $this->module->startPageFallback;
131 if($this->module->startPageDynamic) {
132 $_GET[
'path'] = substr($startPage,1);
135 $this->redirect($startPage);
145 private function _noAccess($content)
147 if (Yii::app()->user->isGuest) {
148 $message =
UserModule::t(
'Please login to access required content.');
150 $message =
UserModule::t(
"You don't have enough rights to access this content. You should have such permissions: {permissions}", array(
'{permissions}'=> implode(
', ', $content->getPersonalisationAttributes())));
153 Yii::app()->user->setFlash(
154 Yii::app()->getModule(
'user')->userLoginWidgetFlashError,
157 Yii::app()->user->setReturnUrl($content->getPath());
158 $this->redirect(Yii::app()->getModule(
'user')->loginUrl);
161 public function processOutput($output){
162 $processed = parent::processOutput($output);
163 $headPosition = strpos($processed,
'<head>');
165 preg_match(
"/<head>(?P<head_content>.*)<\/head>/s", $processed, $is_head);
166 if(!empty($is_head)){
167 $is_head = trim($is_head[
'head_content']);
168 $is_head = strlen($is_head) ?
true:
false;
172 if($headPosition && $is_head){
173 $processed = substr_replace($processed, AppHelper::footprint(
'<!-- generated by Gentics Portal.Node -->'), $headPosition, 0);
188 public function getCss($file, $timestamp = null, $combine =
true, $media =
'')
190 Yii::app()->clientScript->registerCssFile($file, $media, $timestamp, $combine,
true,
true);
202 public function getJs($file, $timestamp = null, $combine =
true)
204 Yii::app()->clientScript->registerScriptFile($file, CClientScript::POS_HEAD, $timestamp, $combine,
true,
true);
217 Yii::app()->clientScript->registerCoreScript($file,
true);
225 private function _getContentSource()
227 return Yii::app()->getModule(
'contentSource');