Hello, I’m getting a 500 error whenever i try to index the page. The browsers etc work fine, however it gives a 500 error and error on line 46 of the code
<?php
class Controller extends CController
{
public $layout = '/layouts/site';
public $domain='';
public $idCafe;
public $language='';
/** @var Cafe $cafe */
public $cafe;
/**
* @var array context menu items. This property will be assigned to {@link CMenu::items}.
*/
public $menu = [];
/**
* @var array the breadcrumbs of the current page. The value of this property will
* be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
* for more details on how to specify this property.
*/
public $breadcrumbs = array();
public $keywords = '';
public $description = '';
public function beforeAction($action){
parent::beforeAction($action);
if (!empty(Yii::app()->request->cookies['language']))
$selectedLang=Yii::app()->request->cookies['language']->value;
else {
$systemLangs = Language::codes();
$selectedLang = $systemLangs[0];
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
if (count($lang_parse[1])) {
$userLangs = array_combine($lang_parse[1], $lang_parse[4]);
foreach ($userLangs as $lang => $val) {
if ($val === '') $userLangs[$lang] = 1;
/**
* here it says that the variable $userLangs is undefined
*/
}
arsort($userLangs, SORT_NUMERIC);
}
foreach ($userLangs as $key => $p) {
if (in_array($key, $systemLangs)) {
$selectedLang = $key;
break;
}
}
Yii::app()->request->cookies['language'] = new CHttpCookie('language', $selectedLang,[
'domain'=>MAIN_DOMAIN,
'expire'=>time()+3600*24*365,
'path'=>'/'
]);
}
Yii::app()->setLanguage($selectedLang);
$this->language=$selectedLang;
$domain=Yii::app()->getRequest()->getQuery("domain");
if (!empty($domain))
$cafe=Cafe::model()->findByAttributes(['alias'=>$domain]);
if (!empty($cafe)){
$this->domain=$domain;
$this->cafe=$cafe;
$this->idCafe=$cafe->id;
}
return true;
}
private $_assetsBase;
public function getAssetsBase()
{
if ($this->_assetsBase === null) {
$this->_assetsBase = Yii::app()->assetManager->publish(
Yii::getPathOfAlias('application.assets'),
false,
-1,
YII_DEBUG
);
}
return $this->_assetsBase;
}
}
please help how to solve the problem identifying the language for googlebot? Can i set the default language here or some direct link to open it without error 500?