public function __get($name)
{
$fieldnames = array_merge(array_keys($this->fields), array('post', 'info', 'editlink'));
$filter = false;
if (!in_array($name, $fieldnames) && strpos($name, '_') !== false) {
$field_matches = implode('|', $fieldnames);
if (preg_match('/^(' . $field_matches . ')_(.+)$/', $name, $matches)) {
list($unused, $name, $filter) = $matches;
}
}
switch ($name) {
case 'name':
if (parent::__get($name) == '') {
$out = _t('Anonymous');
} else {
$out = parent::__get($name);
}
break;
case 'post':
$out = $this->get_post();
break;
case 'info':
$out = $this->get_info();
break;
case 'statusname':
$out = self::status_name($this->status);
break;
case 'typename':
$out = self::type_name($this->type);
break;
case 'editlink':
$out = $this->get_editlink();
break;
default:
if (preg_match('#^is_(.+)$#i', $name, $matches)) {
$ts_field = $matches[1];
if ($index = array_search($ts_field, Comment::list_comment_statuses())) {
$out = $this->status == $index;
}
if ($index = array_search($ts_field, Comment::list_comment_types())) {
$out = $this->type == $index;
}
// Dumb check for plurals
$pluralize = function ($s) {
return $s . 's';
};
if ($index = array_search($ts_field, array_map($pluralize, Comment::list_comment_statuses()))) {
$out = $this->status == $index;
}
if ($index = array_search($ts_field, array_map($pluralize, Comment::list_comment_types()))) {
$out = $this->type == $index;
}
} else {
$out = parent::__get($name);
}
break;
}
//$out = parent::__get( $name );
$out = Plugins::filter("comment_{$name}", $out, $this);
if ($filter) {
$out = Plugins::filter("comment_{$name}_{$filter}", $out, $this);
}
return $out;
}