<?php

// -----------------------------------------------------------------
// tady můžete nastavit práva (1 - 3)
// here you can set the rights (1 - 3)
if ($rights>=3):
// -----------------------------------------------------------------

?>

<h2><?php echo($lang_articles_archive); ?></h2>

<?php

$print=mysql_query("SELECT published FROM kcms_articles WHERE published!='0' ORDER by published DESC");
while (list($published) = mysql_fetch_row($print)) {

if (date("Y", $published)!=$previous_year) {

$previous_year=date("Y", $published);

echo "<h3>".date("Y", $published)."</h3>\n\n<p>";

$print2=mysql_query("SELECT published FROM kcms_articles WHERE published>'".mktime(0, 0, 0, 1, 1, $previous_year)."' AND published<'".mktime(23, 59, 59, 12, 31, $previous_year)."' ORDER by published");
while (list($published) = mysql_fetch_row($print2)) {

if (date("m", $published)!=$previous_month) { echo "<a href=\"./admin.php?f=articles_archive&amp;f2=show_month&amp;m=".date("n", $published)."&amp;y=$previous_year\">".date("m", $published)."</a> "; }

$previous_month=date("m", $published);

}

echo "</p>\n\n";

}

}

if ($f2=="show_month"):

?>

<table>
<tr>
<th style="width: 34%;"><?php echo($lang_form_article_title); ?></th>
<th style="width: 15%;"><?php echo($lang_form_section); ?></th>
<th style="width: 17%;"><?php echo($lang_form_create_date); ?></th>
<th style="width: 17%;"><?php echo($lang_form_release_date); ?></th>
<th style="width: 15%;"><?php echo($lang_form_options); ?></th>
</tr>
<?php

$print=mysql_query("SELECT id, quick, title, section, added, published FROM kcms_articles WHERE published>'".mktime(0, 0, 0, $m, 1, $y)."' AND published<'".mktime(23, 59, 59, $m, 31, $y)."' ORDER by published DESC");
while (list($id, $quick, $title, $section, $added, $published) = mysql_fetch_row($print)) {

$section=mysql_query("SELECT name, quick FROM kcms_sections WHERE id='".addslashes($section)."'");
$section=mysql_fetch_array($section);

echo "<tr>
<td><a href=\"/".$section["quick"]."/$quick/\">".stripslashes($title)."</a></td>
<td>".$section["name"]."</td>
<td style=\"text-align: right;\">".date("d.m.Y, H:i", $added)."</td>
<td style=\"text-align: right;\">";

if ($published!=0) { echo (date("d.m.Y, H:i", $published)); } else { echo "$lang_form_not_published_yet"; }

echo "</td>
<td style=\"text-align: center;\"><input type=\"button\" value=\"$lang_button_edit\" onclick=\"parent.location='./admin.php?f=edit_article&amp;id=$id';\" /> <input type=\"button\" value=\"$lang_button_delete\" onclick=\"if (!confirm('$lang_alert_sure')) return false; parent.location='./admin.php?f=articles_archive&amp;f2=show_month&amp;m=$m&amp;y=$y&amp;a=delete_article&amp;id=$id';\" /></td>
</tr>\n";
}

?>
</table>

<?php endif; else: $access_denied=1; endif; ?>