_directory === $directory) {
					// add year to the list (do not closes li, because
					// we may have nested elements)
					$this->_year = $file;
					$lnk = get_year_link($file);
					$this->_list[$this->_year] = "
 20$file";
					return 1;
				} elseif (is_dir($f)) {
					$this->_months[] = $file; 
					return 0;
				}
			}
		}
		
		function _exitingDir() {
			
			$y = $this->_year;
			
			if ($mos =& $this->_months) {
				sort($mos);
				$list = '';
				foreach($mos as $mth) {
					$lnk = get_month_link($y, $mth);
					$list = "". 
						strftime( '%B', mktime(0, 0, 0, $mth, 1, 0 ))
							.' ' . $list;
				}
				$list = '';
			}
			
			$mos = array();
			
			// we close year's li
			$this->_list[$y] .= $list . ''; 
		}
		
		function getList() {
			krsort($this->_list);
			return implode($this->_list);
		}
		
		
}
function plugin_archives_widget() {
	lang_load('plugin:archives');
	global $lang;
	
	$a =& new plugin_archive_monthlist;
	
	return array(
		'subject' => $lang['plugin']['archives']['subject'],
		
		'content' => ($list = $a->getList()) ? 
						'' 
						: 
						"{$lang['plugin']['archives']['no_posts']}
" 
					);		
}
register_widget('archives', 'Archives', 'plugin_archives_widget');
?>