Index: plugins/widgets/_widgets_functions.php
===================================================================
--- plugins/widgets/_widgets_functions.php	(revision 2662)
+++ plugins/widgets/_widgets_functions.php	(revision 2667)
@@ -26,14 +26,12 @@
 		$value = isset($GLOBALS['_search']) ? html::escapeHTML($GLOBALS['_search']) : '';
 
-		return
-		($w->content_only ? '' : '<div id="search"'.($w->class ? ' class="'.html::escapeHTML($w->class).'"' : '').'>').
-		($w->title ? $w->renderTitle('<label for="q">'.html::escapeHTML($w->title).'</label>') : '').
-		'<form action="'.$core->blog->url.'" method="get" role="search">'.
-		'<fieldset>'.
-		'<p><input type="text" size="10" maxlength="255" id="q" name="q" value="'.$value.'" /> '.
-		'<input type="submit" class="submit" value="ok" /></p>'.
-		'</fieldset>'.
-		'</form>'.
-		($w->content_only ? '' : '</div>');
+		return $w->renderDiv($w->content_only,$w->class,'id="search"',
+			($w->title ? $w->renderTitle('<label for="q">'.html::escapeHTML($w->title).'</label>') : '').
+			'<form action="'.$core->blog->url.'" method="get" role="search">'.
+			'<fieldset>'.
+			'<p><input type="text" size="10" maxlength="255" id="q" name="q" value="'.$value.'" /> '.
+			'<input type="submit" class="submit" value="ok" /></p>'.
+			'</fieldset>'.
+			'</form>');
 	}
 
@@ -48,5 +46,4 @@
 
 		$res =
-		($w->content_only ? '' : '<div id="topnav"'.($w->class ? ' class="'.html::escapeHTML($w->class).'"' : '').'>').
 		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
 		'<ul role="navigation">';
@@ -63,8 +60,7 @@
 		'<a href="'.$core->blog->url.$core->url->getURLFor("archive").'">'.
 		__('Archives').'</a></li>'.
-		'</ul>'.
-		($w->content_only ? '' : '</div>');
-
-		return $res;
+		'</ul>';
+
+		return $w->renderDiv($w->content_only,$w->class,'id="topnav"',$res);
 	}
 
@@ -84,5 +80,4 @@
 
 		$res =
-		($w->content_only ? '' : '<div class="categories'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
 		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '');
 
@@ -118,7 +113,6 @@
 			$res .= str_repeat('</li></ul>',-($ref_level - $level));
 		}
-		$res .= ($w->content_only ? '' : '</div>');
-
-		return $res;
+
+		return $w->renderDiv($w->content_only,'categories '.$w->class,'',$res);
 	}
 
@@ -145,5 +139,4 @@
 
 		$res =
-		($w->content_only ? '' : '<div class="selected'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
 		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
 		'<ul>';
@@ -157,7 +150,7 @@
 		}
 
-		$res .= '</ul>'.($w->content_only ? '' : '</div>');
-
-		return $res;
+		$res .= '</ul>';
+
+		return $w->renderDiv($w->content_only,'selected '.$w->class,'',$res);
 	}
 
@@ -179,5 +172,4 @@
 		$langs = l10n::getISOcodes();
 		$res =
-		($w->content_only ? '' : '<div class="langs'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
 		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
 		'<ul>';
@@ -198,7 +190,7 @@
 		}
 
-		$res .= '</ul>'.($w->content_only ? '' : '</div>');
-
-		return $res;
+		$res .= '</ul>';
+
+		return $w->renderDiv($w->content_only,'langs '.$w->class,'',$res);
 	}
 
@@ -219,5 +211,4 @@
 
 		$res =
-		($w->content_only ? '' : '<div class="syndicate'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
 		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
 		'<ul>';
@@ -238,7 +229,7 @@
 		}
 
-		$res .= '</ul>'.($w->content_only ? '' : '</div>');
-
-		return $res;
+		$res .= '</ul>';
+
+		return $w->renderDiv($w->content_only,'syndicate '.$w->class,'',$res);
 	}
 
@@ -268,5 +259,4 @@
 
 		$res =
-		($w->content_only ? '' : '<div class="feed'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
 		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
 		'<ul>';
@@ -293,7 +283,7 @@
 		}
 
-		$res .= '</ul>'.($w->content_only ? '' : '</div>');
-
-		return $res;
+		$res .= '</ul>';
+
+		return $w->renderDiv($w->content_only,'feed '.$w->class,'',$res);
 	}
 
@@ -307,11 +297,7 @@
 		}
 
-		$res =
-		($w->content_only ? '' : '<div class="text'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
-		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
-		$w->text.
-		($w->content_only ? '' : '</div>');
-
-		return $res;
+		$res = ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').$w->text;
+
+		return $w->renderDiv($w->content_only,'text '.$w->class,'',$res);
 	}
 
@@ -355,5 +341,4 @@
 
 		$res =
-		($w->content_only ? '' : '<div class="lastposts'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
 		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
 		'<ul>';
@@ -368,7 +353,7 @@
 		}
 
-		$res .= '</ul>'.($w->content_only ? '' : '</div>');
-
-		return $res;
+		$res .= '</ul>';
+
+		return $w->renderDiv($w->content_only,'lastposts '.$w->class,'',$res);
 	}
 
@@ -390,7 +375,5 @@
 		}
 
-		$res = ($w->content_only ? '' : '<div class="lastcomments'.($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
-		($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
-		'<ul>';
+		$res = ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').'<ul>';
 
 		while ($rs->fetch())
@@ -404,7 +387,7 @@
 		}
 
-		$res .= '</ul>'.($w->content_only ? '' : '</div>');
-
-		return $res;
+		$res .= '</ul>';
+
+		return $w->renderDiv($w->content_only,'lastcomments '.$w->class,'',$res);
 	}
 }
