26
26
class LinkPreviewerPlainText extends LinkPreviewer {
27
27
/**
28
28
* Provisionally support all links (subject to the page to which a
29
- * link refers having a content-type of text/html ).
29
+ * link refers having a content-type of text/plain ).
30
30
*/
31
31
protected $ supported_norm_links_regex = '(^) ' ;
32
32
@@ -64,6 +64,8 @@ class LinkPreviewerPlainText extends LinkPreviewer {
64
64
</a>
65
65
</div> ' ;
66
66
67
+ protected $ max_chars = 83 ;
68
+
67
69
/**
68
70
* Only support previews of plain text content.
69
71
*/
@@ -81,12 +83,10 @@ public function get_preview_data($link, $content, $content_type) {
81
83
return '' ;
82
84
}
83
85
84
- $ max_chars = 83 ;
85
-
86
86
$ description = trim (preg_replace ('( \\s+) ' , ' ' , strip_tags ($ content )));
87
- $ need_ellipsis_desc = strlen ($ description ) > $ max_chars ;
87
+ $ need_ellipsis_desc = strlen ($ description ) > $ this -> max_chars ;
88
88
if ($ need_ellipsis_desc ) {
89
- $ description = my_substr ($ description , 0 , $ max_chars );
89
+ $ description = my_substr ($ description , 0 , $ this -> max_chars );
90
90
}
91
91
$ description_safe = htmlspecialchars_uni ($ description );
92
92
if ($ need_ellipsis_desc ) $ description_safe .= '… ' ;
@@ -102,9 +102,9 @@ protected function get_preview_contents($link, $pv_data) {
102
102
103
103
$ link_safe = htmlspecialchars_uni ($ link );
104
104
$ link_basename = basename ($ link );
105
- $ need_ellipsis_basename = my_strlen ($ link_basename ) > $ max_chars ;
105
+ $ need_ellipsis_basename = my_strlen ($ link_basename ) > $ this -> max_chars ;
106
106
if ($ need_ellipsis_basename ) {
107
- $ link_basename = my_substr ($ link_basename , 0 , $ max_chars );
107
+ $ link_basename = my_substr ($ link_basename , 0 , $ this -> max_chars );
108
108
}
109
109
$ link_basename_safe = htmlspecialchars_uni ($ link_basename );
110
110
if ($ need_ellipsis_basename ) $ link_basename_safe .= '… ' ;
0 commit comments