Notice: Undefined index: lvData in /var/www/////system/widgets/lastvisited/widget.php on line 12
Notice: Undefined index: title-news in /var/www/////system/widgets/lastvisited/widget.php on line 25
Notice: Undefined variable: a in /var/www//////system/widgets/lastvisited/widget.php on line 64
Notice: Undefined variable: style in /var/www/////system/widgets/lastvisited/widget.php on line 95
Notice: Undefined variable: hide_except_title in /var/www//////system/widgets/lastvisited/widget.php on line 103
Notice: Undefined variable: style in /var/www//////system/widgets/lastvisited/widget.php on line 109
Warning: Cannot modify header information — headers already sent by (output started at /var/www/////system/widgets/lastvisited/widget.php:11) in /var/www/////system/core/template.php on line 187
class widgetLastvisited extends cmsWidget {
public $is_cacheable = false;
public function run(){
$op=$this->options;
$opfields=array();
$arr=$_SESSION['lvTime'];
$arrd=$_SESSION['lvData'];
//print_r($op);
if ($arr) {
$arr=cmsModel::yamlToArray($arr);
$arrd=cmsModel::yamlToArray($arrd);
//print_r($arrd);
} else {
$arr=array();
$arrd=array();
}
foreach($op['ctypes'] as $v) {
$opfields[$v]=array('title'=>$op['title-'.$v],
'image'=>$op['image-'.$v],
'teaser'=>$op['teaser-'.$v]);
}
// print_r($opfields);
$core = cmsCore::getInstance();
if ($core->controller == 'content'){
$uri_segs = explode('/', $core->uri);
$ctype_string = $uri_segs[0];
$slug = !mb_strstr($core->uri, '.html')? mb_substr($core->uri, mb_strlen($ctype_string)+1): null;
$matches = array();
if (preg_match('/^([a-z0-9_]+)$/', $ctype_string, $matches)){
$ctype_name = $matches[0];
} else
if (preg_match('/^([a-z0-9_]+)-([a-z0-9_]+)$/', $ctype_string, $matches)){
$ctype_name = $matches[1];
}
$model = cmsCore::getModel('content');
$tree = $model->getContentTypes();
$clist= array_collection_to_list($tree, 'name', 'title');
if (in_array($ctype_name,$op['ctypes']) ) {
$slug = mb_substr($core->uri, mb_strlen($ctype_name)+1);
$slug = mb_substr($slug,0,mb_strlen($slug)-5);
if ($slug) $a=$model->getItemByField('con_'.$ctype_name, 'slug', $slug);
if($a) {
$arr[$ctype_name.$a['id']]=mktime();
$arrd[$ctype_name.$a['id']]=array_merge($a,array('visit'=>date('Y-m-d H:i:s',$arr[$ctype_name.$a['id']]),
'simage'=>cmsModel::yamlToArray($a[$opfields[$ctype_name]['image']]),
'steaser'=>$a[$opfields[$ctype_name]['teaser']],
'ctype'=>$ctype_name,
'ctitle'=>$clist[$ctype_name]
));
arsort($arr);
$newarr=array_slice($arr,0,$op['limit'],true);
$_SESSION['lvTime']=cmsModel::arrayToYaml($newarr);
$neward=array();
foreach($arr as $k=>$v) $neward[$k]=$arrd[$k];
$_SESSION['lvData']=cmsModel::arrayToYaml($neward);
unset($neward[$ctype_name.$a['id']]);
} else $neward=$arrd;
}
}
if($style){
$this->setTemplate('list_'.$style);
} else {
$this->setTemplate($this->tpl_body);
}
$neward=$neward? $neward: $arrd;
return array(
'hide_except_title' => $hide_except_title,
'teaser_len' => $op['teaser_len'],
'title_field' => 'title',
'image_field' => 'simage',
'teaser_field' => 'steaser',
'is_show_details' => $op['show_details'],
'style' => $style,
'items' => $neward,
'show_ctitle' => $op['show_ctitle']
);
}
}
?>
Заранее спасибо.