Gazelle/classes/sitehistoryview.class.php

227 lines
6.7 KiB
PHP
Raw Normal View History

2013-07-28 08:00:53 +00:00
<?
class SiteHistoryView {
public static function render_linkbox() {
if (check_perms('users_mod')
2013-10-13 08:01:01 +00:00
) {
?>
<div class="linkbox">
<a href="sitehistory.php?action=edit" class="brackets">Create new event</a>
</div>
<?
}
2013-07-28 08:00:53 +00:00
}
public static function render_events($Events) {
$Categories = SiteHistory::get_categories();
$SubCategories = SiteHistory::get_sub_categories();
$CanEdit = check_perms('users_mod') ;
2013-10-13 08:01:01 +00:00
foreach ($Events as $Event) {
?>
2013-07-28 08:00:53 +00:00
<div class="box">
<div class="head colhead_dark">
<div class="title">
2013-10-13 08:01:01 +00:00
<? if ($CanEdit) { ?>
2013-07-28 08:00:53 +00:00
<a class="brackets" href="sitehistory.php?action=edit&amp;id=<?=$Event['ID']?>">Edit</a>
2013-10-13 08:01:01 +00:00
<? } ?>
2013-07-28 08:00:53 +00:00
2013-10-13 08:01:01 +00:00
<?=date('F d, Y', strtotime($Event['Date']));?>
-
<a href="sitehistory.php?action=search&amp;category=<?=$Event['Category']?>" class="brackets"><?=$Categories[$Event['Category']]?></a>
<a href="sitehistory.php?action=search&amp;subcategory=<?=$Event['SubCategory']?>" class="brackets"><?=$SubCategories[$Event['SubCategory']]?></a>
2013-07-28 08:00:53 +00:00
2013-10-13 08:01:01 +00:00
<? if (!empty($Event['Url'])) { ?>
2013-07-28 08:00:53 +00:00
<a href="<?=$Event['Url']?>"><?=$Event['Title']?></a>
2013-10-13 08:01:01 +00:00
<? } else { ?>
2013-07-28 08:00:53 +00:00
<?=$Event['Title']?>
2013-10-13 08:01:01 +00:00
<? } ?>
2013-07-28 08:00:53 +00:00
</div>
<div class="tags">
<? self::render_tags($Event['Tags'])?>
</div>
</div>
2013-10-13 08:01:01 +00:00
<? if (!empty($Event['Body'])) { ?>
<div class="body">
2013-12-12 08:01:01 +00:00
<?=Text::full_format($Event['Body'])?>
2013-10-13 08:01:01 +00:00
</div>
<? } ?>
2013-07-28 08:00:53 +00:00
</div>
2013-10-13 08:01:01 +00:00
<?
}
2013-07-28 08:00:53 +00:00
}
private static function render_tags($Tags) {
$Tags = explode(',', $Tags);
natcasesort($Tags);
2013-08-28 23:08:41 +00:00
$FormattedTags = '';
foreach ($Tags as $Tag) {
2013-10-13 08:01:01 +00:00
$FormattedTags .= "<a href=\"sitehistory.php?action=search&amp;tags=$Tag\">$Tag" . "</a>, ";
2013-07-28 08:00:53 +00:00
}
echo rtrim($FormattedTags, ', ');
}
public static function render_months($Months) { ?>
<div class="box">
2013-10-13 08:01:01 +00:00
<div class="head">Calendar</div>
<div class="pad">
<?
$Year = "";
foreach ($Months as $Month) {
if ($Month['Year'] != $Year) {
$Year = $Month['Year'];
echo "<h2>$Year</h2>";
}
?>
<a style="margin-left: 5px;" href="sitehistory.php?month=<?=$Month['Month']?>&amp;year=<?=$Month['Year']?>"><?=$Month['MonthName']?></a>
<? } ?>
2013-07-28 08:00:53 +00:00
</div>
2013-10-13 08:01:01 +00:00
</div>
<?
}
2013-07-28 08:00:53 +00:00
public static function render_search() { ?>
<div class="box">
<div class="head">Search</div>
<div class="pad">
2013-10-13 08:01:01 +00:00
<form class="search_form" action="sitehistory.php" method="get">
2013-07-28 08:00:53 +00:00
<input type="hidden" name="action" value="search" />
2013-10-13 08:01:01 +00:00
<input type="text" id="title" name="title" size="20" placeholder="Title" />
2013-07-28 08:00:53 +00:00
<br /><br/>
2013-10-13 08:01:01 +00:00
<input type="text" id="tags" name="tags" size="20" placeholder="Comma-separated tags" />
2013-07-28 08:00:53 +00:00
<br /><br/>
<select name="category" id="category">
2013-10-13 08:01:01 +00:00
<option value="0">Choose a category</option>
<?
$Categories = SiteHistory::get_categories();
foreach ($Categories as $Key => $Value) {
?>
<option<?=$Key == $Event['Category'] ? ' selected="selected"' : ''?> value="<?=$Key?>"><?=$Value?></option>
<? } ?>
2013-07-28 08:00:53 +00:00
</select>
<br /><br/>
<select name="subcategory">
2013-10-13 08:01:01 +00:00
<option value="0">Choose a subcategory</option>
<?
$SubCategories = SiteHistory::get_sub_categories();
foreach ($SubCategories as $Key => $Value) {
?>
<option<?=$Key == $Event['SubCategory'] ? ' selected="selected"' : ''?> value="<?=$Key?>"><?=$Value?></option>
<? } ?>
2013-07-28 08:00:53 +00:00
</select>
<br /><br/>
<input value="Search" type="submit" />
</form>
</div>
</div>
<? }
public static function render_edit_form($Event) { ?>
2013-10-13 08:01:01 +00:00
<form id="event_form" method="post" action="">
<? if ($Event) { ?>
<input type="hidden" name="action" value="take_edit" />
<input type="hidden" name="id" value="<?=$Event['ID']?>" />
<? } else { ?>
<input type="hidden" name="action" value="take_create" />
<? } ?>
2013-07-28 08:00:53 +00:00
<input type="hidden" name="auth" value="<?=G::$LoggedUser['AuthKey']?>" />
<table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
<tr>
<td class="label">Title:</td>
<td>
<input type="text" id="title" name="title" size="50" class="required" value="<?=$Event['Title']?>" />
</td>
</tr>
<tr>
<td class="label">Link:</td>
<td>
<input type="text" id="url" name="url" size="50" value="<?=$Event['Url']?>" />
</td>
</tr>
<tr>
<td class="label">Date:</td>
<td>
2013-10-13 08:01:01 +00:00
<input type="date" id="date" name="date" class="required"<?=$Event ? ' value="' . date('Y-m-d', strtotime($Event['Date'])) . '"' : ''?> />
2013-07-28 08:00:53 +00:00
</td>
</tr>
<tr>
<td class="label">Category:</td>
<td>
<select id="category" name="category" class="required">
<option value="0">Choose a category</option>
2013-10-13 08:01:01 +00:00
<?
$Categories = SiteHistory::get_categories();
foreach ($Categories as $Key => $Value) {
?>
<option<?=$Key == $Event['Category'] ? ' selected="selected"' : ''?> value="<?=$Key?>"><?=$Value?></option>
<? } ?>
2013-07-28 08:00:53 +00:00
</select>
</td>
</tr>
<tr>
<td class="label">Subcategory:</td>
<td>
<select id="category" name="sub_category" class="required">
<option value="0">Choose a subcategory</option>
2013-10-13 08:01:01 +00:00
<? $SubCategories = SiteHistory::get_sub_categories();
foreach ($SubCategories as $Key => $Value) { ?>
<option<?=$Key == $Event['SubCategory'] ? ' selected="selected"' : ''?> value="<?=$Key?>"><?=$Value?></option>
<? } ?>
2013-07-28 08:00:53 +00:00
</select>
</td>
</tr>
<tr>
<td class="label">Tags:</td>
<td>
2013-10-13 08:01:01 +00:00
<input type="text" id="tags" name="tags" placeholder="Comma-separated tags; use periods/dots for spaces" size="50" value="<?=$Event['Tags']?>" />
2013-07-28 08:00:53 +00:00
<select id="tag_list">
<option>Choose tags</option>
2013-10-13 08:01:01 +00:00
<?
$Tags = SiteHistory::get_tags();
foreach ($Tags as $Tag) {
?>
<option><?=$Tag?></option>
<? } ?>
2013-07-28 08:00:53 +00:00
</select>
</td>
</tr>
<tr>
<td class="label">Body:</td>
<td>
2013-10-13 08:01:01 +00:00
<textarea id="body" name="body" cols="90" rows="8" tabindex="1" onkeyup="resize('body');"><?=$Event['Body']?></textarea>
2013-07-28 08:00:53 +00:00
</td>
</tr>
</table>
<input type="submit" name="submit" value="Submit" />
2013-10-13 08:01:01 +00:00
<? if ($Event) { ?>
<input type="submit" name="delete" value="Delete" />
<? } ?>
2013-07-28 08:00:53 +00:00
</form>
2013-10-13 08:01:01 +00:00
<?
}
2013-07-28 08:00:53 +00:00
public static function render_recent_sidebar($Events) { ?>
<div class="box">
<div class="head colhead_dark">
<strong><a href="sitehistory.php">Latest site history</a></strong>
</div>
<ul class="stats nobullet">
2013-10-13 08:01:01 +00:00
<?
$Categories = SiteHistory::get_categories();
foreach ($Events as $Event) {
?>
2013-07-28 08:00:53 +00:00
<li>
2013-10-13 08:01:01 +00:00
<a href="sitehistory.php?action=search&amp;category=<?=$Event['Category']?>" class="brackets"><?=$Categories[$Event['Category']]?></a>
<? if (!empty($Event['Url'])) { ?>
<a href="<?=$Event['Url']?>"><?=Format::cut_string($Event['Title'], 20)?></a>
<? } else { ?>
<?=Format::cut_string($Event['Title'], 20)?>
<? } ?>
</li>
<? } ?>
2013-07-28 08:00:53 +00:00
</ul>
</div>
2013-10-13 08:01:01 +00:00
<?
}
2013-08-28 23:08:41 +00:00
}