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());
71 $this->_noAccess($content);
75 throw new Exception(
'Path not exists: ' . $this->_getContentSource()->contentSource->contentFile($path));
77 throw new CHttpException(404);
93 if (Yii::app()->request->getParam(
'path',
false)) {
94 $path =
'/' . Yii::app()->request->getParam(
'path',
'');
96 $content = $this->_getContentSource()->getContent($path);
100 if ($content->hasAccess(Yii::app()->user)) {
101 $content = $this->renderFile($content->getFile(), null,
true);
102 echo $this->processOutput($content);
104 $this->_noAccess($content);
108 throw new Exception(
'Path not exists: ' . $this->_getContentSource()->contentSource->contentFile($path));
110 throw new CHttpException(404);
125 throw new CHttpException(404);
128 $folder = Yii::app()->request->getParam(
'folder',
'').
'/';
129 $startPage = $this->module->getContentSource()->getStartPage($folder, substr(Yii::app()->locale->id, 0, 2));
131 if($startPage ===
false) {
132 $startPage =
'/' . Yii::app()->request->getParam(
'path',
'') . $folder . $this->module->startPageFallback;
135 if($this->module->startPageDynamic) {
136 $_GET[
'path'] = substr($startPage,1);
139 $this->redirect($startPage);
149 private function _noAccess($content)
151 if (Yii::app()->user->isGuest) {
152 $message =
UserModule::t(
'Please login to access required content.');
154 $message =
UserModule::t(
"You don't have enough rights to access this content. You should have such permissions: {permissions}", array(
'{permissions}'=> implode(
', ', $content->getPersonalisationAttributes())));
157 Yii::app()->user->setFlash(
158 Yii::app()->getModule(
'user')->userLoginWidgetFlashError,
161 Yii::app()->user->setReturnUrl($content->getPath());
162 $this->redirect(Yii::app()->getModule(
'user')->loginUrl);
165 public function processOutput($output){
166 $processed = parent::processOutput($output);
167 $headPosition = strpos($processed,
'<head>');
169 preg_match(
"/<head>(?P<head_content>.*)<\/head>/s", $processed, $is_head);
170 if(!empty($is_head)){
171 $is_head = trim($is_head[
'head_content']);
172 $is_head = strlen($is_head) ?
true:
false;
176 if($headPosition && $is_head){
177 $processed = substr_replace($processed, AppHelper::footprint(
'<!-- generated by Gentics Portal.Node -->'), $headPosition, 0);
178 if(isset($_GET[
'error'])){
179 $error_code = $_GET[
'error'];
180 $error_msg = self::getStatusText($error_code);
181 header(
"HTTP/1.1 $error_code $error_msg");
187 static function getStatusText($code){
189 $status_codes = array (
192 101 =>
'Switching Protocols',
197 203 =>
'Non-Authoritative Information',
199 205 =>
'Reset Content',
200 206 =>
'Partial Content',
201 207 =>
'Multi-Status',
202 300 =>
'Multiple Choices',
203 301 =>
'Moved Permanently',
206 304 =>
'Not Modified',
208 307 =>
'Temporary Redirect',
209 400 =>
'Bad Request',
210 401 =>
'Unauthorized',
211 402 =>
'Payment Required',
214 405 =>
'Method Not Allowed',
215 406 =>
'Not Acceptable',
216 407 =>
'Proxy Authentication Required',
217 408 =>
'Request Timeout',
220 411 =>
'Length Required',
221 412 =>
'Precondition Failed',
222 413 =>
'Request Entity Too Large',
223 414 =>
'Request-URI Too Long',
224 415 =>
'Unsupported Media Type',
225 416 =>
'Requested Range Not Satisfiable',
226 417 =>
'Expectation Failed',
227 422 =>
'Unprocessable Entity',
229 424 =>
'Failed Dependency',
230 426 =>
'Upgrade Required',
231 500 =>
'Internal Server Error',
232 501 =>
'Not Implemented',
233 502 =>
'Bad Gateway',
234 503 =>
'Service Unavailable',
235 504 =>
'Gateway Timeout',
236 505 =>
'HTTP Version Not Supported',
237 506 =>
'Variant Also Negotiates',
238 507 =>
'Insufficient Storage',
239 509 =>
'Bandwidth Limit Exceeded',
240 510 =>
'Not Extended'
243 $msg = isset($status_codes[$code])?$status_codes[$code]:
'An unknown error';
258 public function getCss($file, $timestamp = null, $combine =
true, $media =
'')
260 Yii::app()->clientScript->registerCssFile($file, $media, $timestamp, $combine,
true,
true);
272 public function getJs($file, $timestamp = null, $combine =
true)
274 Yii::app()->clientScript->registerScriptFile($file, CClientScript::POS_HEAD, $timestamp, $combine,
true,
true);
287 Yii::app()->clientScript->registerCoreScript($file,
true);
295 private function _getContentSource()
297 return Yii::app()->getModule(
'contentSource');