@@ -77,7 +77,7 @@ function get_coll_setting_definitions( & $params )
7777 function get_msg_setting_definitions ( & $ params )
7878 {
7979 // set params to allow rendering for messages by default
80- $ default_params = array_merge ( $ params , array ( 'default_msg_rendering ' => 'opt-in ' ) );
80+ $ default_params = array_merge ( $ params , array ( 'default_msg_rendering ' => 'never ' ) );
8181 return parent ::get_msg_setting_definitions ( $ default_params );
8282 }
8383
@@ -91,7 +91,7 @@ function get_msg_setting_definitions( & $params )
9191 function get_email_setting_definitions ( & $ params )
9292 {
9393 // set params to allow rendering for emails by default:
94- $ default_params = array_merge ( $ params , array ( 'default_email_rendering ' => 'opt-in ' ) );
94+ $ default_params = array_merge ( $ params , array ( 'default_email_rendering ' => 'never ' ) );
9595 return parent ::get_email_setting_definitions ( $ default_params );
9696 }
9797
@@ -110,13 +110,53 @@ function get_shared_setting_definitions( & $params )
110110 }
111111
112112
113+ /**
114+ * Event handler: Called at the beginning of the skin's HTML HEAD section.
115+ *
116+ * Use this to add any HTML HEAD lines (like CSS styles or links to resource files (CSS, JavaScript, ..)).
117+ *
118+ * @param array Associative array of parameters
119+ */
120+ function SkinBeginHtmlHead ( & $ params )
121+ {
122+ global $ Collection , $ Blog ;
123+
124+ if ( ! isset ( $ Blog ) || (
125+ $ this ->get_coll_setting ( 'coll_apply_rendering ' , $ Blog ) == 'never ' &&
126+ $ this ->get_coll_setting ( 'coll_apply_comment_rendering ' , $ Blog ) == 'never ' ) )
127+ { // Don't load css/js files when plugin is not enabled:
128+ return ;
129+ }
130+
131+ $ this ->require_css ( 'auto_anchors.css ' );
132+ }
133+
134+
135+ /**
136+ * Event handler: Called when ending the admin html head section.
137+ *
138+ * @param array Associative array of parameters
139+ * @return boolean did we do something?
140+ */
141+ function AdminEndHtmlHead ( & $ params )
142+ {
143+ $ this ->SkinBeginHtmlHead ( $ params );
144+ }
145+
146+
113147 /**
114148 * Perform rendering
115149 */
116150 function RenderItemAsHtml ( & $ params )
117151 {
118152 $ content = & $ params ['data ' ];
119153
154+ // Get current Item to render links for anchors:
155+ if ( ! ( $ this ->current_Item = $ this ->get_Item_from_params ( $ params ) ) )
156+ { // Render anchor link only for Item or Comment:
157+ return true ;
158+ }
159+
120160 // Load for replace_special_chars():
121161 load_funcs ( 'locales/_charset.funcs.php ' );
122162
@@ -150,8 +190,19 @@ function callback_auto_anchor( $m )
150190 return $ m [0 ];
151191 }
152192
153- return $ m [1 ].' id=" ' .$ anchor .'"> ' .$ m [4 ].$ m [5 ];
154- //return $m[1].' id="'.$anchor.'">'.$m[4].' <a href="#'.$anchor.'">'.get_icon( 'merge' ).'</a>'.$m[5];
193+ $ header_tag_start = $ m [1 ];
194+ if ( strpos ( $ header_tag_start , ' class=" ' ) !== false )
195+ { // Append style class to current:
196+ $ header_tag_start = str_replace ( ' class=" ' , ' class="evo_auto_anchor_header ' , $ header_tag_start );
197+ }
198+ else
199+ { // Add new class attribute:
200+ $ header_tag_start .= ' class="evo_auto_anchor_header" ' ;
201+ }
202+
203+ $ anchor_link = ' <a href=" ' .$ this ->current_Item ->get_permanent_url ().'# ' .$ anchor .'" class="evo_auto_anchor_link"> ' .get_icon ( 'merge ' , 'imgtag ' , array ( 'title ' => false ) ).'</a> ' ;
204+
205+ return $ header_tag_start .' id=" ' .$ anchor .'"> ' .$ m [4 ].$ anchor_link .$ m [5 ];
155206 }
156207}
157208
0 commit comments