dos2unixification
This commit is contained in:
parent
4e95149c4b
commit
95eadbdd1f
@ -1,494 +1,494 @@
|
||||
<?php
|
||||
class ArtistsTheme extends Themelet {
|
||||
|
||||
public function get_author_editor_html($author) {
|
||||
$h_author = html_escape($author);
|
||||
return "<tr><td>Author</td><td><input class='editor_author' type='text' name='tag_edit__author' value='$h_author'></td></tr>";
|
||||
}
|
||||
|
||||
public function display_artists(){
|
||||
global $page;
|
||||
|
||||
$page->set_title("Artists");
|
||||
$page->set_heading("Artists");
|
||||
$page->add_block(new Block("Artists", $html, "main", 10));
|
||||
|
||||
//$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
public function sidebar_options($mode, $artistID=NULL, $is_admin=FALSE){
|
||||
global $page;
|
||||
|
||||
if($mode == "neutral"){
|
||||
$html = "<form method='post' action='".make_link("artist/new_artist")."'>
|
||||
<input type='submit' name='edit' id='edit' value='New Artist'/>
|
||||
</form>";
|
||||
}
|
||||
|
||||
if($mode == "editor"){
|
||||
$html = "<form method='post' action='".make_link("artist/new_artist")."'>
|
||||
<input type='submit' name='edit' id='edit' value='New Artist'/>
|
||||
</form>
|
||||
|
||||
<form method='post' action='".make_link("artist/edit_artist")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Edit Artist'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>";
|
||||
|
||||
if($is_admin){
|
||||
$html .= "<form method='post' action='".make_link("artist/nuke_artist")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Delete Artist'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>";
|
||||
}
|
||||
|
||||
$html .= "<form method='post' action='".make_link("artist/add_alias")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Add Alias'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>
|
||||
|
||||
<form method='post' action='".make_link("artist/add_member")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Add Member'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>
|
||||
|
||||
<form method='post' action='".make_link("artist/add_url")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Add Url'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>";
|
||||
}
|
||||
$page->add_block(new Block("Manage Artists", $html, "left", 10));
|
||||
}
|
||||
|
||||
public function show_artist_editor($artist, $aliases, $members, $urls)
|
||||
{
|
||||
$artistName = $artist['name'];
|
||||
$artistNotes = $artist['notes'];
|
||||
$artistID = $artist['id'];
|
||||
|
||||
// aliases
|
||||
$aliasesString = "";
|
||||
$aliasesIDsString = "";
|
||||
foreach ($aliases as $alias)
|
||||
{
|
||||
$aliasesString .= $alias["alias_name"]." ";
|
||||
$aliasesIDsString .= $alias["alias_id"]." ";
|
||||
}
|
||||
$aliasesString = rtrim($aliasesString);
|
||||
$aliasesIDsString = rtrim($aliasesIDsString);
|
||||
|
||||
// members
|
||||
$membersString = "";
|
||||
$membersIDsString = "";
|
||||
foreach ($members as $member)
|
||||
{
|
||||
$membersString .= $member["name"]." ";
|
||||
$membersIDsString .= $member["id"]." ";
|
||||
}
|
||||
$membersString = rtrim($membersString);
|
||||
$membersIDsString = rtrim($membersIDsString);
|
||||
|
||||
// urls
|
||||
$urlsString = "";
|
||||
$urlsIDsString = "";
|
||||
foreach ($urls as $url)
|
||||
{
|
||||
$urlsString .= $url["url"]."\n";
|
||||
$urlsIDsString .= $url["id"]." ";
|
||||
}
|
||||
$urlsString = substr($urlsString, 0, strlen($urlsString) -1);
|
||||
$urlsIDsString = rtrim($urlsIDsString);
|
||||
|
||||
$html =
|
||||
'
|
||||
<form method="POST" action="'.make_link("artist/edited/".$artist['id']).'">
|
||||
<table>
|
||||
<tr><td>Name:</td><td><input type="text" name="name" value="'.$artistName.'" />
|
||||
<input type="hidden" name="id" value="'.$artistID.'" /></td></tr>
|
||||
<tr><td>Alias:</td><td><input type="text" name="aliases" value="'.$aliasesString.'" />
|
||||
<input type="hidden" name="aliasesIDs" value="'.$aliasesIDsString.'" /></td></tr>
|
||||
<tr><td>Members:</td><td><input type="text" name="members" value="'.$membersString.'" />
|
||||
<input type="hidden" name="membersIDs" value="'.$membersIDsString.'" /></td></tr>
|
||||
<tr><td>URLs:</td><td><textarea name="urls">'.$urlsString.'</textarea>
|
||||
<input type="hidden" name="urlsIDs" value="'.$urlsIDsString.'" /></td></tr>
|
||||
<tr><td>Notes:</td><td><textarea name="notes">'.$artistNotes.'</textarea></td></tr>
|
||||
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Edit artist", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function new_artist_composer()
|
||||
{
|
||||
global $page;
|
||||
|
||||
$html = "<form action=".make_link("artist/create")." method='POST'>
|
||||
<table>
|
||||
<tr><td>Name:</td><td><input type='text' name='name' /></td></tr>
|
||||
<tr><td>Aliases:</td><td><input type='text' name='aliases' /></td></tr>
|
||||
<tr><td>Members:</td><td><input type='text' name='members' /></td></tr>
|
||||
<tr><td>URLs:</td><td><textarea name='urls'></textarea></td></tr>
|
||||
<tr><td>Notes:</td><td><textarea name='notes'></textarea></td></tr>
|
||||
<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
|
||||
</table>
|
||||
";
|
||||
|
||||
$page->set_title("Artists");
|
||||
$page->set_heading("Artists");
|
||||
$page->add_block(new Block("Artists", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function list_artists($artists, $pageNumber, $totalPages)
|
||||
{
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Name</th>".
|
||||
"<th>Type</th>".
|
||||
"<th>Last updater</th>".
|
||||
"<th>Posts</th>";
|
||||
|
||||
|
||||
if(!$user->is_anonymous()) $html .= "<th colspan='2'>Action</th>"; // space for edit link
|
||||
|
||||
$html .= "</tr></thead>";
|
||||
|
||||
$n = 0;
|
||||
$deletionLinkActionArray =
|
||||
array('artist' => 'artist/nuke/'
|
||||
, 'alias' => 'artist/alias/delete/'
|
||||
, 'member' => 'artist/member/delete/'
|
||||
);
|
||||
|
||||
$editionLinkActionArray =
|
||||
array('artist' => 'artist/edit/'
|
||||
, 'alias' => 'artist/alias/edit/'
|
||||
, 'member' => 'artist/member/edit/'
|
||||
);
|
||||
|
||||
$typeTextArray =
|
||||
array('artist' => 'Artist'
|
||||
, 'alias' => 'Alias'
|
||||
, 'member' => 'Member'
|
||||
);
|
||||
|
||||
foreach ($artists as $artist)
|
||||
{
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
if ($artist['type'] != 'artist')
|
||||
$artist['name'] = str_replace("_", " ", $artist['name']);
|
||||
|
||||
$elementLink = "<a href='".make_link("artist/view/".$artist['artist_id'])."'>".str_replace("_", " ", $artist['name'])."</a>";
|
||||
$artist_link = "<a href='".make_link("artist/view/".$artist['artist_id'])."'>".str_replace("_", " ", $artist['artist_name'])."</a>";
|
||||
$user_link = "<a href='".make_link("user/".$artist['user_name'])."'>".$artist['user_name']."</a>";
|
||||
$edit_link = "<a href='".make_link($editionLinkActionArray[$artist['type']].$artist['id'])."'>Edit</a>";
|
||||
$del_link = "<a href='".make_link($deletionLinkActionArray[$artist['type']].$artist['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td class='left'>".$elementLink;
|
||||
|
||||
//if ($artist['type'] == 'member')
|
||||
// $html .= " (member of ".$artist_link.")";
|
||||
|
||||
//if ($artist['type'] == 'alias')
|
||||
// $html .= " (alias for ".$artist_link.")";
|
||||
|
||||
$html .= "</td>".
|
||||
"<td>".$typeTextArray[$artist['type']]."</td>".
|
||||
"<td>".$user_link."</td>".
|
||||
"<td>".$artist['posts']."</td>";
|
||||
|
||||
if(!$user->is_anonymous()) $html .= "<td>".$edit_link."</td>";
|
||||
if($user->is_admin()) $html .= "<td>".$del_link."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$page->set_title("Artists");
|
||||
$page->set_heading("Artists");
|
||||
$page->add_block(new Block("Artists", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
public function show_new_alias_composer($artistID)
|
||||
{
|
||||
$html =
|
||||
'<form method="POST" action='.make_link("artist/alias/add").'>
|
||||
<table>
|
||||
<tr><td>Alias:</td><td><input type="text" name="aliases" />
|
||||
<input type="hidden" name="artistID" value='.$artistID.' /></td></tr>
|
||||
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Artist Aliases", $html, "main", 20));
|
||||
}
|
||||
public function show_new_member_composer($artistID)
|
||||
{
|
||||
$html =
|
||||
' <form method="POST" action='.make_link("artist/member/add").'>
|
||||
<table>
|
||||
<tr><td>Members:</td><td><input type="text" name="members" />
|
||||
<input type="hidden" name="artistID" value='.$artistID.' /></td></tr>
|
||||
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Artist members", $html, "main", 30));
|
||||
}
|
||||
|
||||
public function show_new_url_composer($artistID)
|
||||
{
|
||||
$html =
|
||||
' <form method="POST" action='.make_link("artist/url/add").'>
|
||||
<table>
|
||||
<tr><td>URL:</td><td><textarea name="urls"></textarea>
|
||||
<input type="hidden" name="artistID" value='.$artistID.' /></td></tr>
|
||||
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Artist URLs", $html, "main", 40));
|
||||
}
|
||||
|
||||
public function show_alias_editor($alias)
|
||||
{
|
||||
$html =
|
||||
'
|
||||
<form method="POST" action="'.make_link("artist/alias/edited/".$alias['id']).'">
|
||||
<label for="alias">Alias:</label>
|
||||
<input type="text" name="alias" value="'.$alias['alias'].'" />
|
||||
<input type="hidden" name="aliasID" value="'.$alias['id'].'" />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Edit Alias", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function show_url_editor($url)
|
||||
{
|
||||
$html =
|
||||
'
|
||||
<form method="POST" action="'.make_link("artist/url/edited/".$url['id']).'">
|
||||
<label for="url">URL:</label>
|
||||
<input type="text" name="url" value="'.$url['url'].'" />
|
||||
<input type="hidden" name="urlID" value="'.$url['id'].'" />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Edit URL", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function show_member_editor($member)
|
||||
{
|
||||
$html =
|
||||
'
|
||||
<form method="POST" action="'.make_link("artist/member/edited/".$member['id']).'">
|
||||
<label for="member">Member name:</label>
|
||||
<input type="text" name="name" value="'.$member['name'].'" />
|
||||
<input type="hidden" name="memberID" value="'.$member['id'].'" />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Edit Member", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin)
|
||||
{
|
||||
global $user, $event, $page;
|
||||
|
||||
$artist_link = "<a href='".make_link("post/list/".$artist['name']."/1")."'>".str_replace("_", " ", $artist['name'])."</a>";
|
||||
|
||||
$n = 0;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>";
|
||||
|
||||
if ($userIsLogged)
|
||||
$html .= "<th></th>";
|
||||
|
||||
if ($userIsAdmin)
|
||||
$html .= "<th></th>";
|
||||
|
||||
$html .= " <tr>
|
||||
</thead>
|
||||
|
||||
<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>Name:</td>
|
||||
<td class='left'>".$artist_link."</td>";
|
||||
if ($userIsLogged) $html .= "<td></td>";
|
||||
if ($userIsAdmin) $html .= "<td></td>";
|
||||
$html .= "</tr>";
|
||||
|
||||
if (count($aliases) > 0)
|
||||
{
|
||||
$aliasViewLink = str_replace("_", " ", $aliases[0]['alias_name']); // no link anymore
|
||||
$aliasEditLink = "<a href='".make_link("artist/alias/edit/".$aliases[0]['alias_id'])."'>Edit</a>";
|
||||
$aliasDeleteLink = "<a href='".make_link("artist/alias/delete/".$aliases[0]['alias_id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>Aliases:</td>
|
||||
<td class='left'>".$aliasViewLink."</td>";
|
||||
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$aliasEditLink."</td>";
|
||||
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$aliasDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
|
||||
if (count($aliases) > 1)
|
||||
{
|
||||
for ($i = 1; $i < count($aliases); $i++)
|
||||
{
|
||||
$aliasViewLink = str_replace("_", " ", $aliases[$i]['alias_name']); // no link anymore
|
||||
$aliasEditLink = "<a href='".make_link("artist/alias/edit/".$aliases[$i]['alias_id'])."'>Edit</a>";
|
||||
$aliasDeleteLink = "<a href='".make_link("artist/alias/delete/".$aliases[$i]['alias_id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'> </td>
|
||||
<td class='left'>".$aliasViewLink."</td>";
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$aliasEditLink."</td>";
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$aliasDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($members) > 0)
|
||||
{
|
||||
$memberViewLink = str_replace("_", " ", $members[0]['name']); // no link anymore
|
||||
$memberEditLink = "<a href='".make_link("artist/member/edit/".$members[0]['id'])."'>Edit</a>";
|
||||
$memberDeleteLink = "<a href='".make_link("artist/member/delete/".$members[0]['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>Members:</td>
|
||||
<td class='left'>".$memberViewLink."</td>";
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$memberEditLink."</td>";
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$memberDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
|
||||
if (count($members) > 1)
|
||||
{
|
||||
for ($i = 1; $i < count($members); $i++)
|
||||
{
|
||||
$memberViewLink = str_replace("_", " ", $members[$i]['name']); // no link anymore
|
||||
$memberEditLink = "<a href='".make_link("artist/member/edit/".$members[$i]['id'])."'>Edit</a>";
|
||||
$memberDeleteLink = "<a href='".make_link("artist/member/delete/".$members[$i]['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'> </td>
|
||||
<td class='left'>".$memberViewLink."</td>";
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$memberEditLink."</td>";
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$memberDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($urls) > 0)
|
||||
{
|
||||
$urlViewLink = "<a href='".str_replace("_", " ", $urls[0]['url'])."' target='_blank'>".str_replace("_", " ", $urls[0]['url'])."</a>";
|
||||
$urlEditLink = "<a href='".make_link("artist/url/edit/".$urls[0]['id'])."'>Edit</a>";
|
||||
$urlDeleteLink = "<a href='".make_link("artist/url/delete/".$urls[0]['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>URLs:</td>
|
||||
<td class='left'>".$urlViewLink."</td>";
|
||||
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$urlEditLink."</td>";
|
||||
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$urlDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
|
||||
if (count($urls) > 1)
|
||||
{
|
||||
for ($i = 1; $i < count($urls); $i++)
|
||||
{
|
||||
$urlViewLink = "<a href='".str_replace("_", " ", $urls[$i]['url'])."' target='_blank'>".str_replace("_", " ", $urls[$i]['url'])."</a>";
|
||||
$urlEditLink = "<a href='".make_link("artist/url/edit/".$urls[$i]['id'])."'>Edit</a>";
|
||||
$urlDeleteLink = "<a href='".make_link("artist/url/delete/".$urls[$i]['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'> </td>
|
||||
<td class='left'>".$urlViewLink."</td>";
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$urlEditLink."</td>";
|
||||
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$urlDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$html .=
|
||||
"<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>Notes:</td>
|
||||
<td class='left'>".$artist["notes"]."</td>";
|
||||
if ($userIsLogged) $html .= "<td></td>";
|
||||
if ($userIsAdmin) $html .= "<td></td>";
|
||||
//TODO how will notes be edited? On edit artist? (should there be an editartist?) or on a editnotes?
|
||||
//same question for deletion
|
||||
$html .= "</tr>
|
||||
</table>";
|
||||
|
||||
$page->set_title("Artist");
|
||||
$page->set_heading("Artist");
|
||||
$page->add_block(new Block("Artist", $html, "main", 10));
|
||||
|
||||
|
||||
//we show the images for the artist
|
||||
$artist_images = "";
|
||||
foreach($images as $image) {
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$artist_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
}
|
||||
|
||||
$page->add_block(new Block("Artist Images", $artist_images, "main", 20));
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
class ArtistsTheme extends Themelet {
|
||||
|
||||
public function get_author_editor_html($author) {
|
||||
$h_author = html_escape($author);
|
||||
return "<tr><td>Author</td><td><input class='editor_author' type='text' name='tag_edit__author' value='$h_author'></td></tr>";
|
||||
}
|
||||
|
||||
public function display_artists(){
|
||||
global $page;
|
||||
|
||||
$page->set_title("Artists");
|
||||
$page->set_heading("Artists");
|
||||
$page->add_block(new Block("Artists", $html, "main", 10));
|
||||
|
||||
//$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
public function sidebar_options($mode, $artistID=NULL, $is_admin=FALSE){
|
||||
global $page;
|
||||
|
||||
if($mode == "neutral"){
|
||||
$html = "<form method='post' action='".make_link("artist/new_artist")."'>
|
||||
<input type='submit' name='edit' id='edit' value='New Artist'/>
|
||||
</form>";
|
||||
}
|
||||
|
||||
if($mode == "editor"){
|
||||
$html = "<form method='post' action='".make_link("artist/new_artist")."'>
|
||||
<input type='submit' name='edit' id='edit' value='New Artist'/>
|
||||
</form>
|
||||
|
||||
<form method='post' action='".make_link("artist/edit_artist")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Edit Artist'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>";
|
||||
|
||||
if($is_admin){
|
||||
$html .= "<form method='post' action='".make_link("artist/nuke_artist")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Delete Artist'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>";
|
||||
}
|
||||
|
||||
$html .= "<form method='post' action='".make_link("artist/add_alias")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Add Alias'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>
|
||||
|
||||
<form method='post' action='".make_link("artist/add_member")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Add Member'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>
|
||||
|
||||
<form method='post' action='".make_link("artist/add_url")."'>
|
||||
<input type='submit' name='edit' id='edit' value='Add Url'/>
|
||||
<input type='hidden' name='artist_id' value='".$artistID."'>
|
||||
</form>";
|
||||
}
|
||||
$page->add_block(new Block("Manage Artists", $html, "left", 10));
|
||||
}
|
||||
|
||||
public function show_artist_editor($artist, $aliases, $members, $urls)
|
||||
{
|
||||
$artistName = $artist['name'];
|
||||
$artistNotes = $artist['notes'];
|
||||
$artistID = $artist['id'];
|
||||
|
||||
// aliases
|
||||
$aliasesString = "";
|
||||
$aliasesIDsString = "";
|
||||
foreach ($aliases as $alias)
|
||||
{
|
||||
$aliasesString .= $alias["alias_name"]." ";
|
||||
$aliasesIDsString .= $alias["alias_id"]." ";
|
||||
}
|
||||
$aliasesString = rtrim($aliasesString);
|
||||
$aliasesIDsString = rtrim($aliasesIDsString);
|
||||
|
||||
// members
|
||||
$membersString = "";
|
||||
$membersIDsString = "";
|
||||
foreach ($members as $member)
|
||||
{
|
||||
$membersString .= $member["name"]." ";
|
||||
$membersIDsString .= $member["id"]." ";
|
||||
}
|
||||
$membersString = rtrim($membersString);
|
||||
$membersIDsString = rtrim($membersIDsString);
|
||||
|
||||
// urls
|
||||
$urlsString = "";
|
||||
$urlsIDsString = "";
|
||||
foreach ($urls as $url)
|
||||
{
|
||||
$urlsString .= $url["url"]."\n";
|
||||
$urlsIDsString .= $url["id"]." ";
|
||||
}
|
||||
$urlsString = substr($urlsString, 0, strlen($urlsString) -1);
|
||||
$urlsIDsString = rtrim($urlsIDsString);
|
||||
|
||||
$html =
|
||||
'
|
||||
<form method="POST" action="'.make_link("artist/edited/".$artist['id']).'">
|
||||
<table>
|
||||
<tr><td>Name:</td><td><input type="text" name="name" value="'.$artistName.'" />
|
||||
<input type="hidden" name="id" value="'.$artistID.'" /></td></tr>
|
||||
<tr><td>Alias:</td><td><input type="text" name="aliases" value="'.$aliasesString.'" />
|
||||
<input type="hidden" name="aliasesIDs" value="'.$aliasesIDsString.'" /></td></tr>
|
||||
<tr><td>Members:</td><td><input type="text" name="members" value="'.$membersString.'" />
|
||||
<input type="hidden" name="membersIDs" value="'.$membersIDsString.'" /></td></tr>
|
||||
<tr><td>URLs:</td><td><textarea name="urls">'.$urlsString.'</textarea>
|
||||
<input type="hidden" name="urlsIDs" value="'.$urlsIDsString.'" /></td></tr>
|
||||
<tr><td>Notes:</td><td><textarea name="notes">'.$artistNotes.'</textarea></td></tr>
|
||||
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Edit artist", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function new_artist_composer()
|
||||
{
|
||||
global $page;
|
||||
|
||||
$html = "<form action=".make_link("artist/create")." method='POST'>
|
||||
<table>
|
||||
<tr><td>Name:</td><td><input type='text' name='name' /></td></tr>
|
||||
<tr><td>Aliases:</td><td><input type='text' name='aliases' /></td></tr>
|
||||
<tr><td>Members:</td><td><input type='text' name='members' /></td></tr>
|
||||
<tr><td>URLs:</td><td><textarea name='urls'></textarea></td></tr>
|
||||
<tr><td>Notes:</td><td><textarea name='notes'></textarea></td></tr>
|
||||
<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
|
||||
</table>
|
||||
";
|
||||
|
||||
$page->set_title("Artists");
|
||||
$page->set_heading("Artists");
|
||||
$page->add_block(new Block("Artists", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function list_artists($artists, $pageNumber, $totalPages)
|
||||
{
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Name</th>".
|
||||
"<th>Type</th>".
|
||||
"<th>Last updater</th>".
|
||||
"<th>Posts</th>";
|
||||
|
||||
|
||||
if(!$user->is_anonymous()) $html .= "<th colspan='2'>Action</th>"; // space for edit link
|
||||
|
||||
$html .= "</tr></thead>";
|
||||
|
||||
$n = 0;
|
||||
$deletionLinkActionArray =
|
||||
array('artist' => 'artist/nuke/'
|
||||
, 'alias' => 'artist/alias/delete/'
|
||||
, 'member' => 'artist/member/delete/'
|
||||
);
|
||||
|
||||
$editionLinkActionArray =
|
||||
array('artist' => 'artist/edit/'
|
||||
, 'alias' => 'artist/alias/edit/'
|
||||
, 'member' => 'artist/member/edit/'
|
||||
);
|
||||
|
||||
$typeTextArray =
|
||||
array('artist' => 'Artist'
|
||||
, 'alias' => 'Alias'
|
||||
, 'member' => 'Member'
|
||||
);
|
||||
|
||||
foreach ($artists as $artist)
|
||||
{
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
if ($artist['type'] != 'artist')
|
||||
$artist['name'] = str_replace("_", " ", $artist['name']);
|
||||
|
||||
$elementLink = "<a href='".make_link("artist/view/".$artist['artist_id'])."'>".str_replace("_", " ", $artist['name'])."</a>";
|
||||
$artist_link = "<a href='".make_link("artist/view/".$artist['artist_id'])."'>".str_replace("_", " ", $artist['artist_name'])."</a>";
|
||||
$user_link = "<a href='".make_link("user/".$artist['user_name'])."'>".$artist['user_name']."</a>";
|
||||
$edit_link = "<a href='".make_link($editionLinkActionArray[$artist['type']].$artist['id'])."'>Edit</a>";
|
||||
$del_link = "<a href='".make_link($deletionLinkActionArray[$artist['type']].$artist['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td class='left'>".$elementLink;
|
||||
|
||||
//if ($artist['type'] == 'member')
|
||||
// $html .= " (member of ".$artist_link.")";
|
||||
|
||||
//if ($artist['type'] == 'alias')
|
||||
// $html .= " (alias for ".$artist_link.")";
|
||||
|
||||
$html .= "</td>".
|
||||
"<td>".$typeTextArray[$artist['type']]."</td>".
|
||||
"<td>".$user_link."</td>".
|
||||
"<td>".$artist['posts']."</td>";
|
||||
|
||||
if(!$user->is_anonymous()) $html .= "<td>".$edit_link."</td>";
|
||||
if($user->is_admin()) $html .= "<td>".$del_link."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$page->set_title("Artists");
|
||||
$page->set_heading("Artists");
|
||||
$page->add_block(new Block("Artists", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
public function show_new_alias_composer($artistID)
|
||||
{
|
||||
$html =
|
||||
'<form method="POST" action='.make_link("artist/alias/add").'>
|
||||
<table>
|
||||
<tr><td>Alias:</td><td><input type="text" name="aliases" />
|
||||
<input type="hidden" name="artistID" value='.$artistID.' /></td></tr>
|
||||
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Artist Aliases", $html, "main", 20));
|
||||
}
|
||||
public function show_new_member_composer($artistID)
|
||||
{
|
||||
$html =
|
||||
' <form method="POST" action='.make_link("artist/member/add").'>
|
||||
<table>
|
||||
<tr><td>Members:</td><td><input type="text" name="members" />
|
||||
<input type="hidden" name="artistID" value='.$artistID.' /></td></tr>
|
||||
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Artist members", $html, "main", 30));
|
||||
}
|
||||
|
||||
public function show_new_url_composer($artistID)
|
||||
{
|
||||
$html =
|
||||
' <form method="POST" action='.make_link("artist/url/add").'>
|
||||
<table>
|
||||
<tr><td>URL:</td><td><textarea name="urls"></textarea>
|
||||
<input type="hidden" name="artistID" value='.$artistID.' /></td></tr>
|
||||
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Artist URLs", $html, "main", 40));
|
||||
}
|
||||
|
||||
public function show_alias_editor($alias)
|
||||
{
|
||||
$html =
|
||||
'
|
||||
<form method="POST" action="'.make_link("artist/alias/edited/".$alias['id']).'">
|
||||
<label for="alias">Alias:</label>
|
||||
<input type="text" name="alias" value="'.$alias['alias'].'" />
|
||||
<input type="hidden" name="aliasID" value="'.$alias['id'].'" />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Edit Alias", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function show_url_editor($url)
|
||||
{
|
||||
$html =
|
||||
'
|
||||
<form method="POST" action="'.make_link("artist/url/edited/".$url['id']).'">
|
||||
<label for="url">URL:</label>
|
||||
<input type="text" name="url" value="'.$url['url'].'" />
|
||||
<input type="hidden" name="urlID" value="'.$url['id'].'" />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Edit URL", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function show_member_editor($member)
|
||||
{
|
||||
$html =
|
||||
'
|
||||
<form method="POST" action="'.make_link("artist/member/edited/".$member['id']).'">
|
||||
<label for="member">Member name:</label>
|
||||
<input type="text" name="name" value="'.$member['name'].'" />
|
||||
<input type="hidden" name="memberID" value="'.$member['id'].'" />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
';
|
||||
|
||||
global $page;
|
||||
$page->add_block(new Block("Edit Member", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin)
|
||||
{
|
||||
global $user, $event, $page;
|
||||
|
||||
$artist_link = "<a href='".make_link("post/list/".$artist['name']."/1")."'>".str_replace("_", " ", $artist['name'])."</a>";
|
||||
|
||||
$n = 0;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>";
|
||||
|
||||
if ($userIsLogged)
|
||||
$html .= "<th></th>";
|
||||
|
||||
if ($userIsAdmin)
|
||||
$html .= "<th></th>";
|
||||
|
||||
$html .= " <tr>
|
||||
</thead>
|
||||
|
||||
<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>Name:</td>
|
||||
<td class='left'>".$artist_link."</td>";
|
||||
if ($userIsLogged) $html .= "<td></td>";
|
||||
if ($userIsAdmin) $html .= "<td></td>";
|
||||
$html .= "</tr>";
|
||||
|
||||
if (count($aliases) > 0)
|
||||
{
|
||||
$aliasViewLink = str_replace("_", " ", $aliases[0]['alias_name']); // no link anymore
|
||||
$aliasEditLink = "<a href='".make_link("artist/alias/edit/".$aliases[0]['alias_id'])."'>Edit</a>";
|
||||
$aliasDeleteLink = "<a href='".make_link("artist/alias/delete/".$aliases[0]['alias_id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>Aliases:</td>
|
||||
<td class='left'>".$aliasViewLink."</td>";
|
||||
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$aliasEditLink."</td>";
|
||||
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$aliasDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
|
||||
if (count($aliases) > 1)
|
||||
{
|
||||
for ($i = 1; $i < count($aliases); $i++)
|
||||
{
|
||||
$aliasViewLink = str_replace("_", " ", $aliases[$i]['alias_name']); // no link anymore
|
||||
$aliasEditLink = "<a href='".make_link("artist/alias/edit/".$aliases[$i]['alias_id'])."'>Edit</a>";
|
||||
$aliasDeleteLink = "<a href='".make_link("artist/alias/delete/".$aliases[$i]['alias_id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'> </td>
|
||||
<td class='left'>".$aliasViewLink."</td>";
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$aliasEditLink."</td>";
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$aliasDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($members) > 0)
|
||||
{
|
||||
$memberViewLink = str_replace("_", " ", $members[0]['name']); // no link anymore
|
||||
$memberEditLink = "<a href='".make_link("artist/member/edit/".$members[0]['id'])."'>Edit</a>";
|
||||
$memberDeleteLink = "<a href='".make_link("artist/member/delete/".$members[0]['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>Members:</td>
|
||||
<td class='left'>".$memberViewLink."</td>";
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$memberEditLink."</td>";
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$memberDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
|
||||
if (count($members) > 1)
|
||||
{
|
||||
for ($i = 1; $i < count($members); $i++)
|
||||
{
|
||||
$memberViewLink = str_replace("_", " ", $members[$i]['name']); // no link anymore
|
||||
$memberEditLink = "<a href='".make_link("artist/member/edit/".$members[$i]['id'])."'>Edit</a>";
|
||||
$memberDeleteLink = "<a href='".make_link("artist/member/delete/".$members[$i]['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'> </td>
|
||||
<td class='left'>".$memberViewLink."</td>";
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$memberEditLink."</td>";
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$memberDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($urls) > 0)
|
||||
{
|
||||
$urlViewLink = "<a href='".str_replace("_", " ", $urls[0]['url'])."' target='_blank'>".str_replace("_", " ", $urls[0]['url'])."</a>";
|
||||
$urlEditLink = "<a href='".make_link("artist/url/edit/".$urls[0]['id'])."'>Edit</a>";
|
||||
$urlDeleteLink = "<a href='".make_link("artist/url/delete/".$urls[0]['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>URLs:</td>
|
||||
<td class='left'>".$urlViewLink."</td>";
|
||||
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$urlEditLink."</td>";
|
||||
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$urlDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
|
||||
if (count($urls) > 1)
|
||||
{
|
||||
for ($i = 1; $i < count($urls); $i++)
|
||||
{
|
||||
$urlViewLink = "<a href='".str_replace("_", " ", $urls[$i]['url'])."' target='_blank'>".str_replace("_", " ", $urls[$i]['url'])."</a>";
|
||||
$urlEditLink = "<a href='".make_link("artist/url/edit/".$urls[$i]['id'])."'>Edit</a>";
|
||||
$urlDeleteLink = "<a href='".make_link("artist/url/delete/".$urls[$i]['id'])."'>Delete</a>";
|
||||
|
||||
$html .= "<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'> </td>
|
||||
<td class='left'>".$urlViewLink."</td>";
|
||||
if ($userIsLogged)
|
||||
$html .= "<td class='left'>".$urlEditLink."</td>";
|
||||
|
||||
if ($userIsAdmin)
|
||||
$html .= "<td class='left'>".$urlDeleteLink."</td>";
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$html .=
|
||||
"<tr class='".(($n++ % 2 == 0) ? "even" : "odd")."'>
|
||||
<td class='left'>Notes:</td>
|
||||
<td class='left'>".$artist["notes"]."</td>";
|
||||
if ($userIsLogged) $html .= "<td></td>";
|
||||
if ($userIsAdmin) $html .= "<td></td>";
|
||||
//TODO how will notes be edited? On edit artist? (should there be an editartist?) or on a editnotes?
|
||||
//same question for deletion
|
||||
$html .= "</tr>
|
||||
</table>";
|
||||
|
||||
$page->set_title("Artist");
|
||||
$page->set_heading("Artist");
|
||||
$page->add_block(new Block("Artist", $html, "main", 10));
|
||||
|
||||
|
||||
//we show the images for the artist
|
||||
$artist_images = "";
|
||||
foreach($images as $image) {
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$artist_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
}
|
||||
|
||||
$page->add_block(new Block("Artist Images", $artist_images, "main", 20));
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,43 +1,43 @@
|
||||
<?php
|
||||
|
||||
class FavoritesTheme extends Themelet {
|
||||
public function get_voter_html(Image $image, $is_favorited) {
|
||||
global $page, $user;
|
||||
|
||||
$i_image_id = int_escape($image->id);
|
||||
if(!$is_favorited) {
|
||||
$html = "<form action='".make_link("change_favorite")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='favorite_action' value='set'>
|
||||
<input type='submit' value='Favorite'>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
else {
|
||||
$html = "<form action='".make_link("change_favorite")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='favorite_action' value='unset'>
|
||||
<input type='submit' value='Un-Favorite'>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function display_people($username_array) {
|
||||
global $page;
|
||||
|
||||
$i_favorites = count($username_array);
|
||||
$html = "$i_favorites people:";
|
||||
|
||||
foreach($username_array as $row) {
|
||||
$username = html_escape($row['name']);
|
||||
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
|
||||
}
|
||||
|
||||
$page->add_block(new Block("Favorited By", $html, "left", 25));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
class FavoritesTheme extends Themelet {
|
||||
public function get_voter_html(Image $image, $is_favorited) {
|
||||
global $page, $user;
|
||||
|
||||
$i_image_id = int_escape($image->id);
|
||||
if(!$is_favorited) {
|
||||
$html = "<form action='".make_link("change_favorite")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='favorite_action' value='set'>
|
||||
<input type='submit' value='Favorite'>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
else {
|
||||
$html = "<form action='".make_link("change_favorite")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='favorite_action' value='unset'>
|
||||
<input type='submit' value='Un-Favorite'>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function display_people($username_array) {
|
||||
global $page;
|
||||
|
||||
$i_favorites = count($username_array);
|
||||
$html = "$i_favorites people:";
|
||||
|
||||
foreach($username_array as $row) {
|
||||
$username = html_escape($row['name']);
|
||||
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
|
||||
}
|
||||
|
||||
$page->add_block(new Block("Favorited By", $html, "left", 25));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,395 +1,395 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: [Beta] Forum
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* Alpha <alpha@furries.com.ar>
|
||||
* License: GPLv2
|
||||
* Description: Rough forum extension
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class Forum extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
|
||||
// shortcut to latest
|
||||
|
||||
if ($config->get_int("forum_version") < 1)
|
||||
{
|
||||
$database->create_table("forum_threads", "
|
||||
id SCORE_AIPK,
|
||||
sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
uptodate DATETIME NOT NULL,
|
||||
INDEX (date)
|
||||
");
|
||||
|
||||
$database->create_table("forum_posts",
|
||||
" id SCORE_AIPK,
|
||||
thread_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
message TEXT,
|
||||
INDEX (date),
|
||||
FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
");
|
||||
|
||||
$config->set_int("forum_version", 1);
|
||||
$config->set_int("forumTitleSubString", 25);
|
||||
$config->set_int("forumThreadsPerPage", 15);
|
||||
$config->set_int("forumPostsPerPage", 15);
|
||||
|
||||
$config->set_int("forumMaxCharsPerPost", 512);
|
||||
|
||||
log_info("forum", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||
$sb = new SetupBlock("Forum");
|
||||
$sb->add_int_option("forumTitleSubString", "Title max long: ");
|
||||
$sb->add_int_option("forumThreadsPerPage", "<br>Threads per page: ");
|
||||
$sb->add_int_option("forumPostsPerPage", "<br>Posts per page: ");
|
||||
|
||||
$sb->add_int_option("forumMaxCharsPerPost", "<br>Max chars per post: ");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
public function onUserPageBuilding($event) {
|
||||
global $page, $user, $database;
|
||||
|
||||
$threads_count = $database->db->GetOne("SELECT COUNT(*) FROM forum_threads WHERE user_id=?", array($event->display_user->id));
|
||||
$posts_count = $database->db->GetOne("SELECT COUNT(*) FROM forum_posts WHERE user_id=?", array($event->display_user->id));
|
||||
|
||||
$days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
|
||||
|
||||
$threads_rate = sprintf("%.1f", ($threads_count / $days_old));
|
||||
$posts_rate = sprintf("%.1f", ($posts_count / $days_old));
|
||||
|
||||
$event->add_stats("Forum threads: $threads_count, $threads_rate per day");
|
||||
$event->add_stats("Forum posts: $posts_count, $posts_rate per day");
|
||||
}
|
||||
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
|
||||
if($event->page_matches("forum")) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "index":
|
||||
{
|
||||
$this->show_last_threads($page, $event, $user->is_admin());
|
||||
if(!$user->is_anonymous()) $this->theme->display_new_thread_composer($page);
|
||||
break;
|
||||
}
|
||||
case "view":
|
||||
{
|
||||
$threadID = int_escape($event->get_arg(1));
|
||||
$pageNumber = int_escape($event->get_arg(2));
|
||||
|
||||
$this->show_posts($event, $user->is_admin());
|
||||
if($user->is_admin()) $this->theme->add_actions_block($page, $threadID);
|
||||
if(!$user->is_anonymous()) $this->theme->display_new_post_composer($page, $threadID);
|
||||
break;
|
||||
}
|
||||
case "new":
|
||||
{
|
||||
global $page;
|
||||
$this->theme->display_new_thread_composer($page);
|
||||
break;
|
||||
}
|
||||
case "create":
|
||||
{
|
||||
$redirectTo = "forum/index";
|
||||
if (!$user->is_anonymous())
|
||||
{
|
||||
list($hasErrors, $errors) = $this->valid_values_for_new_thread();
|
||||
|
||||
if($hasErrors)
|
||||
{
|
||||
$this->theme->display_error($page, "Error", $errors);
|
||||
$this->theme->display_new_thread_composer($page, $_POST["message"], $_POST["title"], false);
|
||||
break;
|
||||
}
|
||||
|
||||
$newThreadID = $this->save_new_thread($user);
|
||||
$this->save_new_post($newThreadID, $user);
|
||||
$redirectTo = "forum/view/".$newThreadID."/1";
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link($redirectTo));
|
||||
|
||||
break;
|
||||
}
|
||||
case "delete":
|
||||
$threadID = int_escape($event->get_arg(1));
|
||||
$postID = int_escape($event->get_arg(2));
|
||||
|
||||
if ($user->is_admin()) {$this->delete_post($postID);}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("forum/view/".$threadID));
|
||||
break;
|
||||
case "nuke":
|
||||
$threadID = int_escape($event->get_arg(1));
|
||||
|
||||
if ($user->is_admin())
|
||||
$this->delete_thread($threadID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("forum/index"));
|
||||
break;
|
||||
case "answer":
|
||||
if (!$user->is_anonymous())
|
||||
{
|
||||
list($hasErrors, $errors) = $this->valid_values_for_new_post();
|
||||
|
||||
if ($hasErrors)
|
||||
{
|
||||
$this->theme->display_error($page, "Error", $errors);
|
||||
$this->theme->display_new_post_composer($page, $_POST["threadID"], $_POST["message"], $_POST["title"], false);
|
||||
break;
|
||||
}
|
||||
|
||||
$threadID = int_escape($_POST["threadID"]);
|
||||
|
||||
$this->save_new_post($threadID, $user);
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("forum/view/".$threadID."/1"));
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("forum/index"));
|
||||
//$this->theme->display_error($page, "Invalid action", "You should check forum/index.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function get_total_pages_for_thread($threadID)
|
||||
{
|
||||
global $database, $config;
|
||||
$result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = ?", array($threadID));
|
||||
|
||||
return ceil($result["count"] / $config->get_int("forumPostsPerPage"));
|
||||
}
|
||||
|
||||
private function valid_values_for_new_thread()
|
||||
{
|
||||
$hasErrors = false;
|
||||
|
||||
$errors = "";
|
||||
|
||||
if (!array_key_exists("title", $_POST))
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>No title supplied.</div>";
|
||||
}
|
||||
else if (strlen($_POST["title"]) == 0)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>You cannot have an empty title.</div>";
|
||||
}
|
||||
else if (strlen(mysql_real_escape_string(html_escape($_POST["title"]))) > 255)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>Your title is too long.</div>";
|
||||
}
|
||||
|
||||
if (!array_key_exists("message", $_POST))
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>No message supplied.</div>";
|
||||
}
|
||||
else if (strlen($_POST["message"]) == 0)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>You cannot have an empty message.</div>";
|
||||
}
|
||||
|
||||
return array($hasErrors, $errors);
|
||||
}
|
||||
private function valid_values_for_new_post()
|
||||
{
|
||||
$hasErrors = false;
|
||||
|
||||
$errors = "";
|
||||
if (!array_key_exists("threadID", $_POST))
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors = "<div id='error'>No thread ID supplied.</div>";
|
||||
}
|
||||
else if (strlen($_POST["threadID"]) == 0)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors = "<div id='error'>No thread ID supplied.</div>";
|
||||
}
|
||||
else if (is_numeric($_POST["threadID"]))
|
||||
|
||||
if (!array_key_exists("message", $_POST))
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>No message supplied.</div>";
|
||||
}
|
||||
else if (strlen($_POST["message"]) == 0)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>You cannot have an empty message.</div>";
|
||||
}
|
||||
|
||||
return array($hasErrors, $errors);
|
||||
}
|
||||
private function get_thread_title($threadID)
|
||||
{
|
||||
global $database;
|
||||
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = ? ", array($threadID));
|
||||
return $result["title"];
|
||||
}
|
||||
|
||||
private function show_last_threads(Page $page, $event, $showAdminOptions = false)
|
||||
{
|
||||
global $config, $database;
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||
$pageNumber = 0;
|
||||
else if ($pageNumber <= 0)
|
||||
$pageNumber = 0;
|
||||
else
|
||||
$pageNumber--;
|
||||
|
||||
$threadsPerPage = $config->get_int('forumThreadsPerPage', 15);
|
||||
|
||||
$threads = $database->get_all(
|
||||
"SELECT f.id, f.sticky, f.title, f.date, f.uptodate, u.name AS user_name, u.email AS user_email, u.admin AS user_admin, sum(1) - 1 AS response_count ".
|
||||
"FROM forum_threads AS f ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON f.user_id = u.id ".
|
||||
"INNER JOIN forum_posts AS p ".
|
||||
"ON p.thread_id = f.id ".
|
||||
"GROUP BY f.id, f.sticky, f.title, f.date, u.name, u.email, u.admin ".
|
||||
"ORDER BY f.sticky ASC, f.uptodate DESC LIMIT ?, ?"
|
||||
, array($pageNumber * $threadsPerPage, $threadsPerPage)
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM forum_threads") / $threadsPerPage);
|
||||
|
||||
$this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
private function show_posts($event, $showAdminOptions = false)
|
||||
{
|
||||
global $config, $database, $user;
|
||||
|
||||
$threadID = $event->get_arg(1);
|
||||
$pageNumber = $event->get_arg(2);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||
$pageNumber = 0;
|
||||
else if ($pageNumber <= 0)
|
||||
$pageNumber = 0;
|
||||
else
|
||||
$pageNumber--;
|
||||
|
||||
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
||||
|
||||
$posts = $database->get_all(
|
||||
"SELECT p.id, p.date, p.message, u.name as user_name, u.email AS user_email, u.admin AS user_admin ".
|
||||
"FROM forum_posts AS p ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON p.user_id = u.id ".
|
||||
"WHERE thread_id = ? ".
|
||||
"ORDER BY p.date ASC ".
|
||||
"LIMIT ?, ? "
|
||||
, array($threadID, $pageNumber * $postsPerPage, $postsPerPage)
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM forum_posts WHERE thread_id = ?", array($threadID)) / $postsPerPage);
|
||||
|
||||
$threadTitle = $this->get_thread_title($threadID);
|
||||
|
||||
$this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
private function save_new_thread($user)
|
||||
{
|
||||
$title = mysql_real_escape_string(html_escape($_POST["title"]));
|
||||
$sticky = html_escape($_POST["sticky"]);
|
||||
|
||||
if($sticky == ""){
|
||||
$sticky = "N";
|
||||
}
|
||||
|
||||
global $database;
|
||||
$database->execute("
|
||||
INSERT INTO forum_threads
|
||||
(title, sticky, user_id, date, uptodate)
|
||||
VALUES
|
||||
(?, ?, ?, now(), now())",
|
||||
array($title, $sticky, $user->id));
|
||||
|
||||
$result = $database->get_row("SELECT LAST_INSERT_ID() AS threadID", array());
|
||||
|
||||
log_info("forum", "Thread {$result["threadID"]} created by {$user->name}");
|
||||
|
||||
return $result["threadID"];
|
||||
}
|
||||
|
||||
private function save_new_post($threadID, $user)
|
||||
{
|
||||
global $config;
|
||||
$userID = $user->id;
|
||||
$message = mysql_real_escape_string(html_escape($_POST["message"]));
|
||||
|
||||
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
||||
$message = substr($message, 0, $max_characters);
|
||||
|
||||
global $database;
|
||||
$database->execute("INSERT INTO forum_posts
|
||||
(thread_id, user_id, date, message)
|
||||
VALUES
|
||||
(?, ?, now(), ?)"
|
||||
, array($threadID, $userID, $message));
|
||||
|
||||
$result = $database->get_row("SELECT LAST_INSERT_ID() AS postID", array());
|
||||
|
||||
log_info("forum", "Post {$result["postID"]} created by {$user->name}");
|
||||
|
||||
$database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=?", array ($threadID));
|
||||
}
|
||||
|
||||
private function retrieve_posts($threadID, $pageNumber)
|
||||
{
|
||||
global $database, $config;
|
||||
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
||||
|
||||
return $database->get_all(
|
||||
"SELECT p.id, p.date, p.message, u.name as user_name, u.email AS user_email, u.admin AS user_admin ".
|
||||
"FROM forum_posts AS p ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON p.user_id = u.id ".
|
||||
"WHERE thread_id = ? ".
|
||||
"ORDER BY p.date ASC ".
|
||||
"LIMIT ?, ? "
|
||||
, array($threadID, ($pageNumber - 1) * $postsPerPage, $postsPerPage));
|
||||
}
|
||||
|
||||
private function delete_thread($threadID)
|
||||
{
|
||||
global $database;
|
||||
$database->execute("DELETE FROM forum_threads WHERE id = ?", array($threadID));
|
||||
$database->execute("DELETE FROM forum_posts WHERE thread_id = ?", array($threadID));
|
||||
}
|
||||
|
||||
private function delete_post($postID)
|
||||
{
|
||||
global $database;
|
||||
$database->execute("DELETE FROM forum_posts WHERE id = ?", array($postID));
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Name: [Beta] Forum
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* Alpha <alpha@furries.com.ar>
|
||||
* License: GPLv2
|
||||
* Description: Rough forum extension
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class Forum extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
|
||||
// shortcut to latest
|
||||
|
||||
if ($config->get_int("forum_version") < 1)
|
||||
{
|
||||
$database->create_table("forum_threads", "
|
||||
id SCORE_AIPK,
|
||||
sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
uptodate DATETIME NOT NULL,
|
||||
INDEX (date)
|
||||
");
|
||||
|
||||
$database->create_table("forum_posts",
|
||||
" id SCORE_AIPK,
|
||||
thread_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
message TEXT,
|
||||
INDEX (date),
|
||||
FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
");
|
||||
|
||||
$config->set_int("forum_version", 1);
|
||||
$config->set_int("forumTitleSubString", 25);
|
||||
$config->set_int("forumThreadsPerPage", 15);
|
||||
$config->set_int("forumPostsPerPage", 15);
|
||||
|
||||
$config->set_int("forumMaxCharsPerPost", 512);
|
||||
|
||||
log_info("forum", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||
$sb = new SetupBlock("Forum");
|
||||
$sb->add_int_option("forumTitleSubString", "Title max long: ");
|
||||
$sb->add_int_option("forumThreadsPerPage", "<br>Threads per page: ");
|
||||
$sb->add_int_option("forumPostsPerPage", "<br>Posts per page: ");
|
||||
|
||||
$sb->add_int_option("forumMaxCharsPerPost", "<br>Max chars per post: ");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
public function onUserPageBuilding($event) {
|
||||
global $page, $user, $database;
|
||||
|
||||
$threads_count = $database->db->GetOne("SELECT COUNT(*) FROM forum_threads WHERE user_id=?", array($event->display_user->id));
|
||||
$posts_count = $database->db->GetOne("SELECT COUNT(*) FROM forum_posts WHERE user_id=?", array($event->display_user->id));
|
||||
|
||||
$days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
|
||||
|
||||
$threads_rate = sprintf("%.1f", ($threads_count / $days_old));
|
||||
$posts_rate = sprintf("%.1f", ($posts_count / $days_old));
|
||||
|
||||
$event->add_stats("Forum threads: $threads_count, $threads_rate per day");
|
||||
$event->add_stats("Forum posts: $posts_count, $posts_rate per day");
|
||||
}
|
||||
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
|
||||
if($event->page_matches("forum")) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "index":
|
||||
{
|
||||
$this->show_last_threads($page, $event, $user->is_admin());
|
||||
if(!$user->is_anonymous()) $this->theme->display_new_thread_composer($page);
|
||||
break;
|
||||
}
|
||||
case "view":
|
||||
{
|
||||
$threadID = int_escape($event->get_arg(1));
|
||||
$pageNumber = int_escape($event->get_arg(2));
|
||||
|
||||
$this->show_posts($event, $user->is_admin());
|
||||
if($user->is_admin()) $this->theme->add_actions_block($page, $threadID);
|
||||
if(!$user->is_anonymous()) $this->theme->display_new_post_composer($page, $threadID);
|
||||
break;
|
||||
}
|
||||
case "new":
|
||||
{
|
||||
global $page;
|
||||
$this->theme->display_new_thread_composer($page);
|
||||
break;
|
||||
}
|
||||
case "create":
|
||||
{
|
||||
$redirectTo = "forum/index";
|
||||
if (!$user->is_anonymous())
|
||||
{
|
||||
list($hasErrors, $errors) = $this->valid_values_for_new_thread();
|
||||
|
||||
if($hasErrors)
|
||||
{
|
||||
$this->theme->display_error($page, "Error", $errors);
|
||||
$this->theme->display_new_thread_composer($page, $_POST["message"], $_POST["title"], false);
|
||||
break;
|
||||
}
|
||||
|
||||
$newThreadID = $this->save_new_thread($user);
|
||||
$this->save_new_post($newThreadID, $user);
|
||||
$redirectTo = "forum/view/".$newThreadID."/1";
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link($redirectTo));
|
||||
|
||||
break;
|
||||
}
|
||||
case "delete":
|
||||
$threadID = int_escape($event->get_arg(1));
|
||||
$postID = int_escape($event->get_arg(2));
|
||||
|
||||
if ($user->is_admin()) {$this->delete_post($postID);}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("forum/view/".$threadID));
|
||||
break;
|
||||
case "nuke":
|
||||
$threadID = int_escape($event->get_arg(1));
|
||||
|
||||
if ($user->is_admin())
|
||||
$this->delete_thread($threadID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("forum/index"));
|
||||
break;
|
||||
case "answer":
|
||||
if (!$user->is_anonymous())
|
||||
{
|
||||
list($hasErrors, $errors) = $this->valid_values_for_new_post();
|
||||
|
||||
if ($hasErrors)
|
||||
{
|
||||
$this->theme->display_error($page, "Error", $errors);
|
||||
$this->theme->display_new_post_composer($page, $_POST["threadID"], $_POST["message"], $_POST["title"], false);
|
||||
break;
|
||||
}
|
||||
|
||||
$threadID = int_escape($_POST["threadID"]);
|
||||
|
||||
$this->save_new_post($threadID, $user);
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("forum/view/".$threadID."/1"));
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("forum/index"));
|
||||
//$this->theme->display_error($page, "Invalid action", "You should check forum/index.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function get_total_pages_for_thread($threadID)
|
||||
{
|
||||
global $database, $config;
|
||||
$result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = ?", array($threadID));
|
||||
|
||||
return ceil($result["count"] / $config->get_int("forumPostsPerPage"));
|
||||
}
|
||||
|
||||
private function valid_values_for_new_thread()
|
||||
{
|
||||
$hasErrors = false;
|
||||
|
||||
$errors = "";
|
||||
|
||||
if (!array_key_exists("title", $_POST))
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>No title supplied.</div>";
|
||||
}
|
||||
else if (strlen($_POST["title"]) == 0)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>You cannot have an empty title.</div>";
|
||||
}
|
||||
else if (strlen(mysql_real_escape_string(html_escape($_POST["title"]))) > 255)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>Your title is too long.</div>";
|
||||
}
|
||||
|
||||
if (!array_key_exists("message", $_POST))
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>No message supplied.</div>";
|
||||
}
|
||||
else if (strlen($_POST["message"]) == 0)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>You cannot have an empty message.</div>";
|
||||
}
|
||||
|
||||
return array($hasErrors, $errors);
|
||||
}
|
||||
private function valid_values_for_new_post()
|
||||
{
|
||||
$hasErrors = false;
|
||||
|
||||
$errors = "";
|
||||
if (!array_key_exists("threadID", $_POST))
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors = "<div id='error'>No thread ID supplied.</div>";
|
||||
}
|
||||
else if (strlen($_POST["threadID"]) == 0)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors = "<div id='error'>No thread ID supplied.</div>";
|
||||
}
|
||||
else if (is_numeric($_POST["threadID"]))
|
||||
|
||||
if (!array_key_exists("message", $_POST))
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>No message supplied.</div>";
|
||||
}
|
||||
else if (strlen($_POST["message"]) == 0)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>You cannot have an empty message.</div>";
|
||||
}
|
||||
|
||||
return array($hasErrors, $errors);
|
||||
}
|
||||
private function get_thread_title($threadID)
|
||||
{
|
||||
global $database;
|
||||
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = ? ", array($threadID));
|
||||
return $result["title"];
|
||||
}
|
||||
|
||||
private function show_last_threads(Page $page, $event, $showAdminOptions = false)
|
||||
{
|
||||
global $config, $database;
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||
$pageNumber = 0;
|
||||
else if ($pageNumber <= 0)
|
||||
$pageNumber = 0;
|
||||
else
|
||||
$pageNumber--;
|
||||
|
||||
$threadsPerPage = $config->get_int('forumThreadsPerPage', 15);
|
||||
|
||||
$threads = $database->get_all(
|
||||
"SELECT f.id, f.sticky, f.title, f.date, f.uptodate, u.name AS user_name, u.email AS user_email, u.admin AS user_admin, sum(1) - 1 AS response_count ".
|
||||
"FROM forum_threads AS f ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON f.user_id = u.id ".
|
||||
"INNER JOIN forum_posts AS p ".
|
||||
"ON p.thread_id = f.id ".
|
||||
"GROUP BY f.id, f.sticky, f.title, f.date, u.name, u.email, u.admin ".
|
||||
"ORDER BY f.sticky ASC, f.uptodate DESC LIMIT ?, ?"
|
||||
, array($pageNumber * $threadsPerPage, $threadsPerPage)
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM forum_threads") / $threadsPerPage);
|
||||
|
||||
$this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
private function show_posts($event, $showAdminOptions = false)
|
||||
{
|
||||
global $config, $database, $user;
|
||||
|
||||
$threadID = $event->get_arg(1);
|
||||
$pageNumber = $event->get_arg(2);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||
$pageNumber = 0;
|
||||
else if ($pageNumber <= 0)
|
||||
$pageNumber = 0;
|
||||
else
|
||||
$pageNumber--;
|
||||
|
||||
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
||||
|
||||
$posts = $database->get_all(
|
||||
"SELECT p.id, p.date, p.message, u.name as user_name, u.email AS user_email, u.admin AS user_admin ".
|
||||
"FROM forum_posts AS p ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON p.user_id = u.id ".
|
||||
"WHERE thread_id = ? ".
|
||||
"ORDER BY p.date ASC ".
|
||||
"LIMIT ?, ? "
|
||||
, array($threadID, $pageNumber * $postsPerPage, $postsPerPage)
|
||||
);
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM forum_posts WHERE thread_id = ?", array($threadID)) / $postsPerPage);
|
||||
|
||||
$threadTitle = $this->get_thread_title($threadID);
|
||||
|
||||
$this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
private function save_new_thread($user)
|
||||
{
|
||||
$title = mysql_real_escape_string(html_escape($_POST["title"]));
|
||||
$sticky = html_escape($_POST["sticky"]);
|
||||
|
||||
if($sticky == ""){
|
||||
$sticky = "N";
|
||||
}
|
||||
|
||||
global $database;
|
||||
$database->execute("
|
||||
INSERT INTO forum_threads
|
||||
(title, sticky, user_id, date, uptodate)
|
||||
VALUES
|
||||
(?, ?, ?, now(), now())",
|
||||
array($title, $sticky, $user->id));
|
||||
|
||||
$result = $database->get_row("SELECT LAST_INSERT_ID() AS threadID", array());
|
||||
|
||||
log_info("forum", "Thread {$result["threadID"]} created by {$user->name}");
|
||||
|
||||
return $result["threadID"];
|
||||
}
|
||||
|
||||
private function save_new_post($threadID, $user)
|
||||
{
|
||||
global $config;
|
||||
$userID = $user->id;
|
||||
$message = mysql_real_escape_string(html_escape($_POST["message"]));
|
||||
|
||||
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
||||
$message = substr($message, 0, $max_characters);
|
||||
|
||||
global $database;
|
||||
$database->execute("INSERT INTO forum_posts
|
||||
(thread_id, user_id, date, message)
|
||||
VALUES
|
||||
(?, ?, now(), ?)"
|
||||
, array($threadID, $userID, $message));
|
||||
|
||||
$result = $database->get_row("SELECT LAST_INSERT_ID() AS postID", array());
|
||||
|
||||
log_info("forum", "Post {$result["postID"]} created by {$user->name}");
|
||||
|
||||
$database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=?", array ($threadID));
|
||||
}
|
||||
|
||||
private function retrieve_posts($threadID, $pageNumber)
|
||||
{
|
||||
global $database, $config;
|
||||
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
||||
|
||||
return $database->get_all(
|
||||
"SELECT p.id, p.date, p.message, u.name as user_name, u.email AS user_email, u.admin AS user_admin ".
|
||||
"FROM forum_posts AS p ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON p.user_id = u.id ".
|
||||
"WHERE thread_id = ? ".
|
||||
"ORDER BY p.date ASC ".
|
||||
"LIMIT ?, ? "
|
||||
, array($threadID, ($pageNumber - 1) * $postsPerPage, $postsPerPage));
|
||||
}
|
||||
|
||||
private function delete_thread($threadID)
|
||||
{
|
||||
global $database;
|
||||
$database->execute("DELETE FROM forum_threads WHERE id = ?", array($threadID));
|
||||
$database->execute("DELETE FROM forum_posts WHERE thread_id = ?", array($threadID));
|
||||
}
|
||||
|
||||
private function delete_post($postID)
|
||||
{
|
||||
global $database;
|
||||
$database->execute("DELETE FROM forum_posts WHERE id = ?", array($postID));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,229 +1,229 @@
|
||||
<?php
|
||||
class ForumTheme extends Themelet {
|
||||
|
||||
public function display_thread_list(Page $page, $threads, $showAdminOptions, $pageNumber, $totalPages)
|
||||
{
|
||||
if (count($threads) == 0)
|
||||
$html = "There are no threads to show.";
|
||||
else
|
||||
$html = $this->make_thread_list($threads, $showAdminOptions);
|
||||
|
||||
$page->set_title(html_escape("Forum"));
|
||||
$page->set_heading(html_escape("Forum"));
|
||||
$page->add_block(new Block("Forum", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "forum/index", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function display_new_thread_composer(Page $page, $threadText = null, $threadTitle = null)
|
||||
{
|
||||
global $config, $user;
|
||||
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
||||
$postUrl = make_link("forum/create");
|
||||
$html = '<form action="'.$postUrl.'" method="POST">';
|
||||
|
||||
|
||||
if (!is_null($threadTitle))
|
||||
$threadTitle = html_escape($threadTitle);
|
||||
|
||||
if(!is_null($threadText))
|
||||
$threadText = html_escape($threadText);
|
||||
|
||||
$html .= "
|
||||
<table style='width: 500px;'>
|
||||
<tr><td>Title:</td><td><input type='text' name='title' value='$threadTitle'></td></tr>
|
||||
<tr><td>Message:</td><td><textarea id='message' name='message' >$threadText</textarea></td></tr>
|
||||
<tr><td></td><td><small>Max characters alowed: $max_characters.</small></td></tr>";
|
||||
if($user->is_admin()){
|
||||
$html .= "<tr><td colspan='2'><label for='sticky'>Sticky:</label><input name='sticky' type='checkbox' value='Y' /></td></tr>";
|
||||
}
|
||||
$html .= "<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$blockTitle = "Write a new thread";
|
||||
$page->set_title(html_escape($blockTitle));
|
||||
$page->set_heading(html_escape($blockTitle));
|
||||
$page->add_block(new Block($blockTitle, $html, "main", 20));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function display_new_post_composer(Page $page, $threadID)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
||||
|
||||
$postUrl = make_link("forum/answer");
|
||||
$html = '<form action="'.$postUrl.'" method="POST">';
|
||||
|
||||
$html .= '<input type="hidden" name="threadID" value="'.$threadID.'" />';
|
||||
|
||||
$html .= "
|
||||
<table style='width: 500px;'>
|
||||
<tr><td>Message:</td><td><textarea id='message' name='message' ></textarea>
|
||||
<tr><td></td><td><small>Max characters alowed: $max_characters.</small></td></tr>
|
||||
</td></tr>";
|
||||
|
||||
$html .= "<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$blockTitle = "Answer to this thread";
|
||||
$page->add_block(new Block($blockTitle, $html, "main", 30));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber, $totalPages)
|
||||
{
|
||||
global $config, $page/*, $user*/;
|
||||
|
||||
$theme_name = $config->get_string('theme');
|
||||
$data_href = $config->get_string('base_href');
|
||||
$base_href = $config->get_string('base_href');
|
||||
|
||||
$html = "";
|
||||
$n = 0;
|
||||
|
||||
$html = "<table id='postList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>User</th>".
|
||||
"<th>Message</th>".
|
||||
"</tr></thead>";
|
||||
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
$message = $post["message"];
|
||||
|
||||
$tfe = new TextFormattingEvent($message);
|
||||
send_event($tfe);
|
||||
$message = $tfe->formatted;
|
||||
|
||||
$message = str_replace('\n\r', '<br>', $message);
|
||||
$message = str_replace('\r\n', '<br>', $message);
|
||||
$message = str_replace('\n', '<br>', $message);
|
||||
$message = str_replace('\r', '<br>', $message);
|
||||
|
||||
$message = stripslashes($message);
|
||||
|
||||
$user = "<a href='".make_link("user/".$post["user_name"]."")."'>".$post["user_name"]."</a>";
|
||||
|
||||
$poster = User::by_name($post["user_name"]);
|
||||
$gravatar = $poster->get_avatar_html();
|
||||
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
if ($post["user_admin"] == "Y") {
|
||||
$rank = "<sup>admin</sup>";
|
||||
} else {
|
||||
$rank = "<sup>user</sup>";
|
||||
}
|
||||
|
||||
$postID = $post['id'];
|
||||
|
||||
//if($user->is_admin()){
|
||||
//$delete_link = "<a href=".make_link("forum/delete/".$threadID."/".$postID).">Delete</a>";
|
||||
//} else {
|
||||
//$delete_link = "";
|
||||
//}
|
||||
|
||||
if($showAdminOptions){
|
||||
$delete_link = "<a href=".make_link("forum/delete/".$threadID."/".$postID).">Delete</a>";
|
||||
}else{
|
||||
$delete_link = "";
|
||||
}
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td class='forum_user'>".$user."<br>".$rank."<br>".$gravatar."</td>".
|
||||
"<td class='forum_message'>".$message."</td>"."</tr>
|
||||
<tr class='$oe'>
|
||||
<td class='forum_subuser'><small>".autodate($post["date"])."</small></td>
|
||||
<td class='forum_submessage'>".$delete_link."</td>
|
||||
</tr>";
|
||||
|
||||
}
|
||||
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$this->display_paginator($page, "forum/view/".$threadID, null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title(html_escape($threadTitle));
|
||||
$page->set_heading(html_escape($threadTitle));
|
||||
$page->add_block(new Block("Thread", $html, "main", 20));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function add_actions_block(Page $page, $threadID)
|
||||
{
|
||||
$html = '<a href="'.make_link("forum/nuke/".$threadID).'">Delete this thread and its posts.</a>';
|
||||
|
||||
$page->add_block(new Block("Admin Actions", $html, "main", 40));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function make_thread_list($threads, $showAdminOptions)
|
||||
{
|
||||
$html = "<table id='threadList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Title</th>".
|
||||
"<th>Author</th>".
|
||||
"<th>Updated</th>".
|
||||
"<th>Responses</th>";
|
||||
|
||||
if($showAdminOptions)
|
||||
{
|
||||
$html .= "<th>Actions</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead><tbody>";
|
||||
|
||||
|
||||
$n = 0;
|
||||
foreach($threads as $thread)
|
||||
{
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
global $config;
|
||||
$titleSubString = $config->get_int('forumTitleSubString');
|
||||
|
||||
if ($titleSubString < strlen($thread["title"]))
|
||||
{
|
||||
$title = substr($thread["title"], 0, $titleSubString);
|
||||
$title = $title."...";
|
||||
} else {
|
||||
$title = $thread["title"];
|
||||
}
|
||||
|
||||
if($thread["sticky"] == "Y"){
|
||||
$sticky = "Sticky: ";
|
||||
} else {
|
||||
$sticky = "";
|
||||
}
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
'<td class="left">'.$sticky.'<a href="'.make_link("forum/view/".$thread["id"]).'">'.$title."</a></td>".
|
||||
'<td><a href="'.make_link("user/".$thread["user_name"]).'">'.$thread["user_name"]."</a></td>".
|
||||
"<td>".autodate($thread["uptodate"])."</td>".
|
||||
"<td>".$thread["response_count"]."</td>";
|
||||
|
||||
if ($showAdminOptions)
|
||||
$html .= '<td><a href="'.make_link("forum/nuke/".$thread["id"]).'" title="Delete '.$title.'">Delete</a></td>';
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
class ForumTheme extends Themelet {
|
||||
|
||||
public function display_thread_list(Page $page, $threads, $showAdminOptions, $pageNumber, $totalPages)
|
||||
{
|
||||
if (count($threads) == 0)
|
||||
$html = "There are no threads to show.";
|
||||
else
|
||||
$html = $this->make_thread_list($threads, $showAdminOptions);
|
||||
|
||||
$page->set_title(html_escape("Forum"));
|
||||
$page->set_heading(html_escape("Forum"));
|
||||
$page->add_block(new Block("Forum", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "forum/index", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function display_new_thread_composer(Page $page, $threadText = null, $threadTitle = null)
|
||||
{
|
||||
global $config, $user;
|
||||
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
||||
$postUrl = make_link("forum/create");
|
||||
$html = '<form action="'.$postUrl.'" method="POST">';
|
||||
|
||||
|
||||
if (!is_null($threadTitle))
|
||||
$threadTitle = html_escape($threadTitle);
|
||||
|
||||
if(!is_null($threadText))
|
||||
$threadText = html_escape($threadText);
|
||||
|
||||
$html .= "
|
||||
<table style='width: 500px;'>
|
||||
<tr><td>Title:</td><td><input type='text' name='title' value='$threadTitle'></td></tr>
|
||||
<tr><td>Message:</td><td><textarea id='message' name='message' >$threadText</textarea></td></tr>
|
||||
<tr><td></td><td><small>Max characters alowed: $max_characters.</small></td></tr>";
|
||||
if($user->is_admin()){
|
||||
$html .= "<tr><td colspan='2'><label for='sticky'>Sticky:</label><input name='sticky' type='checkbox' value='Y' /></td></tr>";
|
||||
}
|
||||
$html .= "<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$blockTitle = "Write a new thread";
|
||||
$page->set_title(html_escape($blockTitle));
|
||||
$page->set_heading(html_escape($blockTitle));
|
||||
$page->add_block(new Block($blockTitle, $html, "main", 20));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function display_new_post_composer(Page $page, $threadID)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
||||
|
||||
$postUrl = make_link("forum/answer");
|
||||
$html = '<form action="'.$postUrl.'" method="POST">';
|
||||
|
||||
$html .= '<input type="hidden" name="threadID" value="'.$threadID.'" />';
|
||||
|
||||
$html .= "
|
||||
<table style='width: 500px;'>
|
||||
<tr><td>Message:</td><td><textarea id='message' name='message' ></textarea>
|
||||
<tr><td></td><td><small>Max characters alowed: $max_characters.</small></td></tr>
|
||||
</td></tr>";
|
||||
|
||||
$html .= "<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$blockTitle = "Answer to this thread";
|
||||
$page->add_block(new Block($blockTitle, $html, "main", 30));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber, $totalPages)
|
||||
{
|
||||
global $config, $page/*, $user*/;
|
||||
|
||||
$theme_name = $config->get_string('theme');
|
||||
$data_href = $config->get_string('base_href');
|
||||
$base_href = $config->get_string('base_href');
|
||||
|
||||
$html = "";
|
||||
$n = 0;
|
||||
|
||||
$html = "<table id='postList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>User</th>".
|
||||
"<th>Message</th>".
|
||||
"</tr></thead>";
|
||||
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
$message = $post["message"];
|
||||
|
||||
$tfe = new TextFormattingEvent($message);
|
||||
send_event($tfe);
|
||||
$message = $tfe->formatted;
|
||||
|
||||
$message = str_replace('\n\r', '<br>', $message);
|
||||
$message = str_replace('\r\n', '<br>', $message);
|
||||
$message = str_replace('\n', '<br>', $message);
|
||||
$message = str_replace('\r', '<br>', $message);
|
||||
|
||||
$message = stripslashes($message);
|
||||
|
||||
$user = "<a href='".make_link("user/".$post["user_name"]."")."'>".$post["user_name"]."</a>";
|
||||
|
||||
$poster = User::by_name($post["user_name"]);
|
||||
$gravatar = $poster->get_avatar_html();
|
||||
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
if ($post["user_admin"] == "Y") {
|
||||
$rank = "<sup>admin</sup>";
|
||||
} else {
|
||||
$rank = "<sup>user</sup>";
|
||||
}
|
||||
|
||||
$postID = $post['id'];
|
||||
|
||||
//if($user->is_admin()){
|
||||
//$delete_link = "<a href=".make_link("forum/delete/".$threadID."/".$postID).">Delete</a>";
|
||||
//} else {
|
||||
//$delete_link = "";
|
||||
//}
|
||||
|
||||
if($showAdminOptions){
|
||||
$delete_link = "<a href=".make_link("forum/delete/".$threadID."/".$postID).">Delete</a>";
|
||||
}else{
|
||||
$delete_link = "";
|
||||
}
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td class='forum_user'>".$user."<br>".$rank."<br>".$gravatar."</td>".
|
||||
"<td class='forum_message'>".$message."</td>"."</tr>
|
||||
<tr class='$oe'>
|
||||
<td class='forum_subuser'><small>".autodate($post["date"])."</small></td>
|
||||
<td class='forum_submessage'>".$delete_link."</td>
|
||||
</tr>";
|
||||
|
||||
}
|
||||
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$this->display_paginator($page, "forum/view/".$threadID, null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title(html_escape($threadTitle));
|
||||
$page->set_heading(html_escape($threadTitle));
|
||||
$page->add_block(new Block("Thread", $html, "main", 20));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function add_actions_block(Page $page, $threadID)
|
||||
{
|
||||
$html = '<a href="'.make_link("forum/nuke/".$threadID).'">Delete this thread and its posts.</a>';
|
||||
|
||||
$page->add_block(new Block("Admin Actions", $html, "main", 40));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function make_thread_list($threads, $showAdminOptions)
|
||||
{
|
||||
$html = "<table id='threadList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Title</th>".
|
||||
"<th>Author</th>".
|
||||
"<th>Updated</th>".
|
||||
"<th>Responses</th>";
|
||||
|
||||
if($showAdminOptions)
|
||||
{
|
||||
$html .= "<th>Actions</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead><tbody>";
|
||||
|
||||
|
||||
$n = 0;
|
||||
foreach($threads as $thread)
|
||||
{
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
global $config;
|
||||
$titleSubString = $config->get_int('forumTitleSubString');
|
||||
|
||||
if ($titleSubString < strlen($thread["title"]))
|
||||
{
|
||||
$title = substr($thread["title"], 0, $titleSubString);
|
||||
$title = $title."...";
|
||||
} else {
|
||||
$title = $thread["title"];
|
||||
}
|
||||
|
||||
if($thread["sticky"] == "Y"){
|
||||
$sticky = "Sticky: ";
|
||||
} else {
|
||||
$sticky = "";
|
||||
}
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
'<td class="left">'.$sticky.'<a href="'.make_link("forum/view/".$thread["id"]).'">'.$title."</a></td>".
|
||||
'<td><a href="'.make_link("user/".$thread["user_name"]).'">'.$thread["user_name"]."</a></td>".
|
||||
"<td>".autodate($thread["uptodate"])."</td>".
|
||||
"<td>".$thread["response_count"]."</td>";
|
||||
|
||||
if ($showAdminOptions)
|
||||
$html .= '<td><a href="'.make_link("forum/nuke/".$thread["id"]).'" title="Delete '.$title.'">Delete</a></td>';
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,374 +1,374 @@
|
||||
<?php
|
||||
class NotesTheme extends Themelet {
|
||||
public function note_button($image_id) {
|
||||
return '
|
||||
<script type="text/javascript">
|
||||
function confirm_action() {
|
||||
var r=confirm("Are You Sure?");
|
||||
if (r==true) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <a href="#" id="addnotelink" >Add a note</a> -->
|
||||
|
||||
<form action="" method="">
|
||||
<input type="button" id="addnote" value="Add Note">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function request_button($image_id) {
|
||||
return '
|
||||
|
||||
<form action="'.make_link("note/add_request").'" method="POST">
|
||||
<input id="noterequest" type="submit" value="Add Note Request">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function nuke_notes_button($image_id) {
|
||||
return '
|
||||
<form action="'.make_link("note/nuke_notes").'" method="POST" ">
|
||||
<input id="noterequest" type="submit" value="Nuke Notes" onclick="return confirm_action()">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function nuke_requests_button($image_id) {
|
||||
return '
|
||||
|
||||
<form action="'.make_link("note/nuke_requests").'" method="POST">
|
||||
<input id="noterequest" type="submit" value="Nuke Requests" onclick="return confirm_action()">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
|
||||
public function search_notes_page(Page $page) { //IN DEVELOPMENT, NOT FULLY WORKING
|
||||
$html = '<form method="GET" action="/furpiledbeta/post/list/note=">
|
||||
<input id="search_input" type="text" name="search"/>
|
||||
<input type="submit" style="display: none;" value="Find"/>
|
||||
</form>';
|
||||
|
||||
$page->set_title(html_escape("Search Note"));
|
||||
$page->set_heading(html_escape("Search Note"));
|
||||
$page->add_block(new Block("Search Note", $html, "main", 10));
|
||||
}
|
||||
|
||||
// check action POST on form
|
||||
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) {
|
||||
$html = "<script type='text/javascript'>
|
||||
|
||||
notes = [";
|
||||
|
||||
foreach($recovered_notes as $note)
|
||||
{
|
||||
$parsedNote = $note["note"];
|
||||
$parsedNote = str_replace("\n", "\\n", $parsedNote);
|
||||
$parsedNote = str_replace("\r", "\\r", $parsedNote);
|
||||
|
||||
$html .= "{'x1':'".$note["x1"]."', ".
|
||||
"'y1':'".$note["y1"]."',".
|
||||
"'height':'".$note["height"]."',".
|
||||
"'width':'".$note["width"]."',".
|
||||
"'note':'".$parsedNote."',".
|
||||
"'note_id':'".$note["id"].
|
||||
"'},";
|
||||
}
|
||||
if (count($recovered_notes) > 0)
|
||||
{
|
||||
substr($html, 0, strlen($html) - 1); // remove final comma
|
||||
}
|
||||
|
||||
$html .= "];
|
||||
";
|
||||
|
||||
$html .= "$(document).ready(function() {
|
||||
$('#main_image').imgNotes(); //If your notes data is is not named notes pass it
|
||||
|
||||
$('#cancelnote').click(function(){
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteform').hide();
|
||||
});
|
||||
|
||||
$('#EditCancelNote').click(function() {
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteEditForm').hide();
|
||||
});
|
||||
|
||||
$('#addnote').click(function(){
|
||||
$('#noteEditForm').hide();
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showaddnote, x1: 120, y1: 90, x2: 280, y2: 210 });
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.note').click(function() {
|
||||
$('#noteform').hide();
|
||||
var imgOffset = $('#main_image').offset();
|
||||
|
||||
var x1 = parseInt(this.style.left) - imgOffset.left;
|
||||
var y1 = parseInt(this.style.top) - imgOffset.top;
|
||||
var width = parseInt(this.style.width);
|
||||
var height = parseInt(this.style.height);
|
||||
var text = $(this).next('.notep').text().replace(/([^>]?)\\n{2}/g, '$1\\n');
|
||||
var id = $(this).next('.notep').next('.noteID').text();
|
||||
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showeditnote, x1: x1, y1: y1, x2: x1 + width, y2: y1 + height });
|
||||
setEditNoteData(x1, y1, width, height, text, id);
|
||||
});
|
||||
});
|
||||
|
||||
function showaddnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + parseInt(area.x1);
|
||||
form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5;
|
||||
|
||||
$('#noteform').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
|
||||
$('#noteform').show();
|
||||
|
||||
$('#noteform').css('z-index', 10000);
|
||||
$('#NoteX1').val(area.x1);
|
||||
$('#NoteY1').val(area.y1);
|
||||
$('#NoteHeight').val(area.height);
|
||||
$('#NoteWidth').val(area.width);
|
||||
}
|
||||
function showeditnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + area.x1;
|
||||
form_top = parseInt(imgOffset.top) + area.y2;
|
||||
|
||||
$('#noteEditForm').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
|
||||
$('#noteEditForm').show();
|
||||
|
||||
$('#noteEditForm').css('z-index', 10000);
|
||||
$('#EditNoteX1').val(area.x1);
|
||||
$('#EditNoteY1').val(area.y1);
|
||||
$('#EditNoteHeight').val(area.height);
|
||||
$('#EditNoteWidth').val(area.width);
|
||||
}
|
||||
function setEditNoteData(x1, y1, width, height, text, id)
|
||||
{
|
||||
$('#EditNoteX1').val(x1);
|
||||
$('#EditNoteY1').val(y1);
|
||||
$('#EditNoteHeight').val(height);
|
||||
$('#EditNoteWidth').val(width);
|
||||
$('#EditNoteNote').text(text);
|
||||
$('#EditNoteID').val(id);
|
||||
$('#DeleteNoteNoteID').val(id);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div id='noteform'>
|
||||
<form id='NoteAddForm' action='".make_link("note/add_note")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='".$image_id."' />
|
||||
<input name='note_x1' type='hidden' value='' id='NoteX1' />
|
||||
<input name='note_y1' type='hidden' value='' id='NoteY1' />
|
||||
<input name='note_height' type='hidden' value='' id='NoteHeight' />
|
||||
<input name='note_width' type='hidden' value='' id='NoteWidth' />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan='2'>
|
||||
<textarea name='note_text' id='NoteNote' ></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type='submit' value='Add Note' /></td>
|
||||
<td><input type='button' value='Cancel' id='cancelnote' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div id='noteEditForm'>
|
||||
<form id='NoteEditForm' action='".make_link("note/edit_note")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='".$image_id."' />
|
||||
<input type='hidden' name='note_id' id='EditNoteID' value='' />
|
||||
<input name='note_x1' type='hidden' value='' id='EditNoteX1' />
|
||||
<input name='note_y1' type='hidden' value='' id='EditNoteY1' />
|
||||
<input name='note_height' type='hidden' value='' id='EditNoteHeight' />
|
||||
<input name='note_width' type='hidden' value='' id='EditNoteWidth' />
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan='2'>
|
||||
<textarea name='note_text' id='EditNoteNote' ></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type='submit' value='Save Note' /></td>
|
||||
<td><input type='button' value='Cancel' id='EditCancelNote' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>";
|
||||
|
||||
if($adminOptions)
|
||||
$html .= "
|
||||
<form id='NoteDeleteForm' action='".make_link("note/delete_note")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='".$image_id."' />
|
||||
<input type='hidden' name='note_id' value='' id='DeleteNoteNoteID' />
|
||||
<table>
|
||||
<tr>
|
||||
<td><input type='submit' value='Delete note' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$html .= "</div>";
|
||||
|
||||
$page->add_block(new Block(null, $html, "main", 1));
|
||||
}
|
||||
|
||||
|
||||
public function display_note_list($images, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$pool_images = '';
|
||||
foreach($images as $pair) {
|
||||
$image = $pair[0];
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
|
||||
|
||||
}
|
||||
$this->display_paginator($page, "note/list", null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title("Notes");
|
||||
$page->set_heading("Notes");
|
||||
$page->add_block(new Block("Notes", $pool_images, "main", 20));
|
||||
}
|
||||
|
||||
public function display_note_requests($images, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$pool_images = '';
|
||||
foreach($images as $pair) {
|
||||
$image = $pair[0];
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
|
||||
|
||||
}
|
||||
$this->display_paginator($page, "requests/list", null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title("Note Requests");
|
||||
$page->set_heading("Note Requests");
|
||||
$page->add_block(new Block("Note Requests", $pool_images, "main", 20));
|
||||
}
|
||||
|
||||
public function display_histories($histories, $pageNumber, $totalPages) {
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Image</th>".
|
||||
"<th>Note</th>".
|
||||
"<th>Body</th>".
|
||||
"<th>Updater</th>".
|
||||
"<th>Date</th>";
|
||||
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>".
|
||||
"<tbody>";
|
||||
|
||||
$n = 0;
|
||||
foreach($histories as $history) {
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
|
||||
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
|
||||
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
|
||||
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td>".$image_link."</td>".
|
||||
"<td>".$history_link."</td>".
|
||||
"<td style='text-align:left;'>".$history['note']."</td>".
|
||||
"<td>".$user_link."</td>".
|
||||
"<td>".autodate($history['date'])."</td>";
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<td>".$revert_link."</td>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$html .= "</tr></tbody></table>";
|
||||
|
||||
$page->set_title("Note Updates");
|
||||
$page->set_heading("Note Updates");
|
||||
$page->add_block(new Block("Note Updates", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
public function display_history($histories, $pageNumber, $totalPages) {
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Image</th>".
|
||||
"<th>Note</th>".
|
||||
"<th>Body</th>".
|
||||
"<th>Updater</th>".
|
||||
"<th>Date</th>";
|
||||
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>".
|
||||
"<tbody>";
|
||||
|
||||
$n = 0;
|
||||
foreach($histories as $history) {
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
|
||||
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
|
||||
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
|
||||
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td>".$image_link."</td>".
|
||||
"<td>".$history_link."</td>".
|
||||
"<td style='text-align:left;'>".$history['note']."</td>".
|
||||
"<td>".$user_link."</td>".
|
||||
"<td>".autodate($history['date'])."</td>";
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<td>".$revert_link."</td>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$html .= "</tr></tbody></table>";
|
||||
|
||||
$page->set_title("Note History");
|
||||
$page->set_heading("Note History");
|
||||
$page->add_block(new Block("Note History", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
class NotesTheme extends Themelet {
|
||||
public function note_button($image_id) {
|
||||
return '
|
||||
<script type="text/javascript">
|
||||
function confirm_action() {
|
||||
var r=confirm("Are You Sure?");
|
||||
if (r==true) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <a href="#" id="addnotelink" >Add a note</a> -->
|
||||
|
||||
<form action="" method="">
|
||||
<input type="button" id="addnote" value="Add Note">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function request_button($image_id) {
|
||||
return '
|
||||
|
||||
<form action="'.make_link("note/add_request").'" method="POST">
|
||||
<input id="noterequest" type="submit" value="Add Note Request">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function nuke_notes_button($image_id) {
|
||||
return '
|
||||
<form action="'.make_link("note/nuke_notes").'" method="POST" ">
|
||||
<input id="noterequest" type="submit" value="Nuke Notes" onclick="return confirm_action()">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function nuke_requests_button($image_id) {
|
||||
return '
|
||||
|
||||
<form action="'.make_link("note/nuke_requests").'" method="POST">
|
||||
<input id="noterequest" type="submit" value="Nuke Requests" onclick="return confirm_action()">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
|
||||
public function search_notes_page(Page $page) { //IN DEVELOPMENT, NOT FULLY WORKING
|
||||
$html = '<form method="GET" action="/furpiledbeta/post/list/note=">
|
||||
<input id="search_input" type="text" name="search"/>
|
||||
<input type="submit" style="display: none;" value="Find"/>
|
||||
</form>';
|
||||
|
||||
$page->set_title(html_escape("Search Note"));
|
||||
$page->set_heading(html_escape("Search Note"));
|
||||
$page->add_block(new Block("Search Note", $html, "main", 10));
|
||||
}
|
||||
|
||||
// check action POST on form
|
||||
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) {
|
||||
$html = "<script type='text/javascript'>
|
||||
|
||||
notes = [";
|
||||
|
||||
foreach($recovered_notes as $note)
|
||||
{
|
||||
$parsedNote = $note["note"];
|
||||
$parsedNote = str_replace("\n", "\\n", $parsedNote);
|
||||
$parsedNote = str_replace("\r", "\\r", $parsedNote);
|
||||
|
||||
$html .= "{'x1':'".$note["x1"]."', ".
|
||||
"'y1':'".$note["y1"]."',".
|
||||
"'height':'".$note["height"]."',".
|
||||
"'width':'".$note["width"]."',".
|
||||
"'note':'".$parsedNote."',".
|
||||
"'note_id':'".$note["id"].
|
||||
"'},";
|
||||
}
|
||||
if (count($recovered_notes) > 0)
|
||||
{
|
||||
substr($html, 0, strlen($html) - 1); // remove final comma
|
||||
}
|
||||
|
||||
$html .= "];
|
||||
";
|
||||
|
||||
$html .= "$(document).ready(function() {
|
||||
$('#main_image').imgNotes(); //If your notes data is is not named notes pass it
|
||||
|
||||
$('#cancelnote').click(function(){
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteform').hide();
|
||||
});
|
||||
|
||||
$('#EditCancelNote').click(function() {
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteEditForm').hide();
|
||||
});
|
||||
|
||||
$('#addnote').click(function(){
|
||||
$('#noteEditForm').hide();
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showaddnote, x1: 120, y1: 90, x2: 280, y2: 210 });
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.note').click(function() {
|
||||
$('#noteform').hide();
|
||||
var imgOffset = $('#main_image').offset();
|
||||
|
||||
var x1 = parseInt(this.style.left) - imgOffset.left;
|
||||
var y1 = parseInt(this.style.top) - imgOffset.top;
|
||||
var width = parseInt(this.style.width);
|
||||
var height = parseInt(this.style.height);
|
||||
var text = $(this).next('.notep').text().replace(/([^>]?)\\n{2}/g, '$1\\n');
|
||||
var id = $(this).next('.notep').next('.noteID').text();
|
||||
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showeditnote, x1: x1, y1: y1, x2: x1 + width, y2: y1 + height });
|
||||
setEditNoteData(x1, y1, width, height, text, id);
|
||||
});
|
||||
});
|
||||
|
||||
function showaddnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + parseInt(area.x1);
|
||||
form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5;
|
||||
|
||||
$('#noteform').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
|
||||
$('#noteform').show();
|
||||
|
||||
$('#noteform').css('z-index', 10000);
|
||||
$('#NoteX1').val(area.x1);
|
||||
$('#NoteY1').val(area.y1);
|
||||
$('#NoteHeight').val(area.height);
|
||||
$('#NoteWidth').val(area.width);
|
||||
}
|
||||
function showeditnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + area.x1;
|
||||
form_top = parseInt(imgOffset.top) + area.y2;
|
||||
|
||||
$('#noteEditForm').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
|
||||
$('#noteEditForm').show();
|
||||
|
||||
$('#noteEditForm').css('z-index', 10000);
|
||||
$('#EditNoteX1').val(area.x1);
|
||||
$('#EditNoteY1').val(area.y1);
|
||||
$('#EditNoteHeight').val(area.height);
|
||||
$('#EditNoteWidth').val(area.width);
|
||||
}
|
||||
function setEditNoteData(x1, y1, width, height, text, id)
|
||||
{
|
||||
$('#EditNoteX1').val(x1);
|
||||
$('#EditNoteY1').val(y1);
|
||||
$('#EditNoteHeight').val(height);
|
||||
$('#EditNoteWidth').val(width);
|
||||
$('#EditNoteNote').text(text);
|
||||
$('#EditNoteID').val(id);
|
||||
$('#DeleteNoteNoteID').val(id);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div id='noteform'>
|
||||
<form id='NoteAddForm' action='".make_link("note/add_note")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='".$image_id."' />
|
||||
<input name='note_x1' type='hidden' value='' id='NoteX1' />
|
||||
<input name='note_y1' type='hidden' value='' id='NoteY1' />
|
||||
<input name='note_height' type='hidden' value='' id='NoteHeight' />
|
||||
<input name='note_width' type='hidden' value='' id='NoteWidth' />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan='2'>
|
||||
<textarea name='note_text' id='NoteNote' ></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type='submit' value='Add Note' /></td>
|
||||
<td><input type='button' value='Cancel' id='cancelnote' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div id='noteEditForm'>
|
||||
<form id='NoteEditForm' action='".make_link("note/edit_note")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='".$image_id."' />
|
||||
<input type='hidden' name='note_id' id='EditNoteID' value='' />
|
||||
<input name='note_x1' type='hidden' value='' id='EditNoteX1' />
|
||||
<input name='note_y1' type='hidden' value='' id='EditNoteY1' />
|
||||
<input name='note_height' type='hidden' value='' id='EditNoteHeight' />
|
||||
<input name='note_width' type='hidden' value='' id='EditNoteWidth' />
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan='2'>
|
||||
<textarea name='note_text' id='EditNoteNote' ></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type='submit' value='Save Note' /></td>
|
||||
<td><input type='button' value='Cancel' id='EditCancelNote' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>";
|
||||
|
||||
if($adminOptions)
|
||||
$html .= "
|
||||
<form id='NoteDeleteForm' action='".make_link("note/delete_note")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='".$image_id."' />
|
||||
<input type='hidden' name='note_id' value='' id='DeleteNoteNoteID' />
|
||||
<table>
|
||||
<tr>
|
||||
<td><input type='submit' value='Delete note' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$html .= "</div>";
|
||||
|
||||
$page->add_block(new Block(null, $html, "main", 1));
|
||||
}
|
||||
|
||||
|
||||
public function display_note_list($images, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$pool_images = '';
|
||||
foreach($images as $pair) {
|
||||
$image = $pair[0];
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
|
||||
|
||||
}
|
||||
$this->display_paginator($page, "note/list", null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title("Notes");
|
||||
$page->set_heading("Notes");
|
||||
$page->add_block(new Block("Notes", $pool_images, "main", 20));
|
||||
}
|
||||
|
||||
public function display_note_requests($images, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$pool_images = '';
|
||||
foreach($images as $pair) {
|
||||
$image = $pair[0];
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
|
||||
|
||||
}
|
||||
$this->display_paginator($page, "requests/list", null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title("Note Requests");
|
||||
$page->set_heading("Note Requests");
|
||||
$page->add_block(new Block("Note Requests", $pool_images, "main", 20));
|
||||
}
|
||||
|
||||
public function display_histories($histories, $pageNumber, $totalPages) {
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Image</th>".
|
||||
"<th>Note</th>".
|
||||
"<th>Body</th>".
|
||||
"<th>Updater</th>".
|
||||
"<th>Date</th>";
|
||||
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>".
|
||||
"<tbody>";
|
||||
|
||||
$n = 0;
|
||||
foreach($histories as $history) {
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
|
||||
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
|
||||
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
|
||||
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td>".$image_link."</td>".
|
||||
"<td>".$history_link."</td>".
|
||||
"<td style='text-align:left;'>".$history['note']."</td>".
|
||||
"<td>".$user_link."</td>".
|
||||
"<td>".autodate($history['date'])."</td>";
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<td>".$revert_link."</td>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$html .= "</tr></tbody></table>";
|
||||
|
||||
$page->set_title("Note Updates");
|
||||
$page->set_heading("Note Updates");
|
||||
$page->add_block(new Block("Note Updates", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
public function display_history($histories, $pageNumber, $totalPages) {
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Image</th>".
|
||||
"<th>Note</th>".
|
||||
"<th>Body</th>".
|
||||
"<th>Updater</th>".
|
||||
"<th>Date</th>";
|
||||
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>".
|
||||
"<tbody>";
|
||||
|
||||
$n = 0;
|
||||
foreach($histories as $history) {
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
|
||||
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
|
||||
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
|
||||
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td>".$image_link."</td>".
|
||||
"<td>".$history_link."</td>".
|
||||
"<td style='text-align:left;'>".$history['note']."</td>".
|
||||
"<td>".$user_link."</td>".
|
||||
"<td>".autodate($history['date'])."</td>";
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<td>".$revert_link."</td>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$html .= "</tr></tbody></table>";
|
||||
|
||||
$page->set_title("Note History");
|
||||
$page->set_heading("Note History");
|
||||
$page->add_block(new Block("Note History", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,54 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: XML Sitemap
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Adds sitemap.xml on request.
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class XMLSitemap extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
if($event->page_matches("sitemap.xml")) {
|
||||
$images = Image::find_images(0, 50, array());
|
||||
$this->do_xml($images);
|
||||
}
|
||||
}
|
||||
|
||||
private function do_xml($images) {
|
||||
global $page;
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/xml");
|
||||
|
||||
$data = "";
|
||||
foreach($images as $image) {
|
||||
$link = make_http(make_link("post/view/{$image->id}"));
|
||||
$posted = date("Y-m-d", $image->posted_timestamp);
|
||||
|
||||
$data .= "
|
||||
<url>
|
||||
<loc>$link</loc>
|
||||
<lastmod>$posted</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
";
|
||||
}
|
||||
|
||||
$base_href = make_http(make_link("post/list"));
|
||||
|
||||
$xml = "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">
|
||||
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
|
||||
<url>
|
||||
<loc>$base_href</loc>
|
||||
<lastmod>2009-01-01</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>1</priority>
|
||||
</url>
|
||||
$data
|
||||
</urlset>
|
||||
";
|
||||
$page->set_data($xml);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Name: XML Sitemap
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Adds sitemap.xml on request.
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class XMLSitemap extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
if($event->page_matches("sitemap.xml")) {
|
||||
$images = Image::find_images(0, 50, array());
|
||||
$this->do_xml($images);
|
||||
}
|
||||
}
|
||||
|
||||
private function do_xml($images) {
|
||||
global $page;
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/xml");
|
||||
|
||||
$data = "";
|
||||
foreach($images as $image) {
|
||||
$link = make_http(make_link("post/view/{$image->id}"));
|
||||
$posted = date("Y-m-d", $image->posted_timestamp);
|
||||
|
||||
$data .= "
|
||||
<url>
|
||||
<loc>$link</loc>
|
||||
<lastmod>$posted</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
";
|
||||
}
|
||||
|
||||
$base_href = make_http(make_link("post/list"));
|
||||
|
||||
$xml = "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">
|
||||
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
|
||||
<url>
|
||||
<loc>$base_href</loc>
|
||||
<lastmod>2009-01-01</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>1</priority>
|
||||
</url>
|
||||
$data
|
||||
</urlset>
|
||||
";
|
||||
$page->set_data($xml);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,219 +1,219 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: Tag History
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Description: Keep a record of tag changes
|
||||
*/
|
||||
|
||||
class Tag_History implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof InitExtEvent)) {
|
||||
$config->set_default_int("history_limit", -1);
|
||||
|
||||
// shimmie is being installed so call install to create the table.
|
||||
if($config->get_int("ext_tag_history_version") < 3) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("tag_history"))
|
||||
{
|
||||
if($event->get_arg(0) == "revert")
|
||||
{
|
||||
// this is a request to revert to a previous version of the tags
|
||||
if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
|
||||
$this->process_revert_request($_POST['revert']);
|
||||
}
|
||||
}
|
||||
else if($event->count_args() == 1)
|
||||
{
|
||||
// must be an attempt to view a tag history
|
||||
$image_id = int_escape($event->get_arg(0));
|
||||
$this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
|
||||
}
|
||||
else {
|
||||
$this->theme->display_global_page($page, $this->get_global_tag_history());
|
||||
}
|
||||
}
|
||||
if(($event instanceof DisplayingImageEvent))
|
||||
{
|
||||
// handle displaying a link on the view page
|
||||
$this->theme->display_history_link($page, $event->image->id);
|
||||
}
|
||||
if(($event instanceof ImageDeletionEvent))
|
||||
{
|
||||
// handle removing of history when an image is deleted
|
||||
$this->delete_all_tag_history($event->image->id);
|
||||
}
|
||||
if(($event instanceof SetupBuildingEvent)) {
|
||||
$sb = new SetupBlock("Tag History");
|
||||
$sb->add_label("Limit to ");
|
||||
$sb->add_int_option("history_limit");
|
||||
$sb->add_label(" entires per image");
|
||||
$sb->add_label("<br>(-1 for unlimited)");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
if(($event instanceof TagSetEvent)) {
|
||||
$this->add_tag_history($event->image, $event->tags);
|
||||
}
|
||||
}
|
||||
|
||||
protected function install()
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
|
||||
if($config->get_int("ext_tag_history_version") < 1) {
|
||||
$database->create_table("tag_histories", "
|
||||
id SCORE_AIPK,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
user_ip SCORE_INET NOT NULL,
|
||||
tags TEXT NOT NULL,
|
||||
date_set DATETIME NOT NULL,
|
||||
INDEX(image_id),
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
");
|
||||
$config->set_int("ext_tag_history_version", 3);
|
||||
}
|
||||
|
||||
if($config->get_int("ext_tag_history_version") == 1) {
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_id INTEGER NOT NULL");
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN date_set DATETIME NOT NULL");
|
||||
$config->set_int("ext_tag_history_version", 2);
|
||||
}
|
||||
|
||||
if($config->get_int("ext_tag_history_version") == 2) {
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_ip CHAR(15) NOT NULL");
|
||||
$config->set_int("ext_tag_history_version", 3);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when a revert request is received
|
||||
*/
|
||||
private function process_revert_request($revert_id)
|
||||
{
|
||||
global $page;
|
||||
// check for the nothing case
|
||||
if($revert_id=="nothing")
|
||||
{
|
||||
// tried to set it too the same thing so ignore it (might be a bot)
|
||||
// go back to the index page with you
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link());
|
||||
return;
|
||||
}
|
||||
|
||||
$revert_id = int_escape($revert_id);
|
||||
|
||||
// lets get this revert id assuming it exists
|
||||
$result = $this->get_tag_history_from_revert($revert_id);
|
||||
|
||||
if($result==null)
|
||||
{
|
||||
// there is no history entry with that id so either the image was deleted
|
||||
// while the user was viewing the history, someone is playing with form
|
||||
// variables or we have messed up in code somewhere.
|
||||
die("Error: No tag history with specified id was found.");
|
||||
}
|
||||
|
||||
// lets get the values out of the result
|
||||
$stored_result_id = $result->fields['id'];
|
||||
$stored_image_id = $result->fields['image_id'];
|
||||
$stored_tags = $result->fields['tags'];
|
||||
|
||||
// all should be ok so we can revert by firing the SetUserTags event.
|
||||
send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags));
|
||||
|
||||
// all should be done now so redirect the user back to the image
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/$stored_image_id"));
|
||||
}
|
||||
|
||||
public function get_tag_history_from_revert($revert_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->execute("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
WHERE tag_histories.id = ?", array($revert_id));
|
||||
return ($row ? $row : null);
|
||||
}
|
||||
|
||||
public function get_tag_history_from_id($image_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
WHERE image_id = ?
|
||||
ORDER BY tag_histories.id DESC",
|
||||
array($image_id));
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
public function get_global_tag_history()
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
ORDER BY tag_histories.id DESC
|
||||
LIMIT 100");
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when an image has been deleted
|
||||
*/
|
||||
private function delete_all_tag_history($image_id)
|
||||
{
|
||||
global $database;
|
||||
$database->execute("DELETE FROM tag_histories WHERE image_id = ?", array($image_id));
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called just before an images tag are changed
|
||||
*/
|
||||
private function add_tag_history($image, $tags)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
global $user;
|
||||
|
||||
$new_tags = Tag::implode($tags);
|
||||
$old_tags = Tag::implode($image->get_tag_array());
|
||||
if($new_tags == $old_tags) return;
|
||||
|
||||
// add a history entry
|
||||
$allowed = $config->get_int("history_limit");
|
||||
if($allowed == 0) return;
|
||||
|
||||
$row = $database->execute("
|
||||
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
|
||||
VALUES (?, ?, ?, ?, now())",
|
||||
array($image->id, $new_tags, $user->id, $_SERVER['REMOTE_ADDR']));
|
||||
|
||||
// if needed remove oldest one
|
||||
if($allowed == -1) return;
|
||||
$entries = $database->db->GetOne("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
if($entries > $allowed)
|
||||
{
|
||||
// TODO: Make these queries better
|
||||
$min_id = $database->db->GetOne("SELECT MIN(id) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
$database->execute("DELETE FROM tag_histories WHERE id = ?", array($min_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Tag_History(), 40); // in before tags are actually set, so that "get current tags" works
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Name: Tag History
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Description: Keep a record of tag changes
|
||||
*/
|
||||
|
||||
class Tag_History implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof InitExtEvent)) {
|
||||
$config->set_default_int("history_limit", -1);
|
||||
|
||||
// shimmie is being installed so call install to create the table.
|
||||
if($config->get_int("ext_tag_history_version") < 3) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("tag_history"))
|
||||
{
|
||||
if($event->get_arg(0) == "revert")
|
||||
{
|
||||
// this is a request to revert to a previous version of the tags
|
||||
if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
|
||||
$this->process_revert_request($_POST['revert']);
|
||||
}
|
||||
}
|
||||
else if($event->count_args() == 1)
|
||||
{
|
||||
// must be an attempt to view a tag history
|
||||
$image_id = int_escape($event->get_arg(0));
|
||||
$this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
|
||||
}
|
||||
else {
|
||||
$this->theme->display_global_page($page, $this->get_global_tag_history());
|
||||
}
|
||||
}
|
||||
if(($event instanceof DisplayingImageEvent))
|
||||
{
|
||||
// handle displaying a link on the view page
|
||||
$this->theme->display_history_link($page, $event->image->id);
|
||||
}
|
||||
if(($event instanceof ImageDeletionEvent))
|
||||
{
|
||||
// handle removing of history when an image is deleted
|
||||
$this->delete_all_tag_history($event->image->id);
|
||||
}
|
||||
if(($event instanceof SetupBuildingEvent)) {
|
||||
$sb = new SetupBlock("Tag History");
|
||||
$sb->add_label("Limit to ");
|
||||
$sb->add_int_option("history_limit");
|
||||
$sb->add_label(" entires per image");
|
||||
$sb->add_label("<br>(-1 for unlimited)");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
if(($event instanceof TagSetEvent)) {
|
||||
$this->add_tag_history($event->image, $event->tags);
|
||||
}
|
||||
}
|
||||
|
||||
protected function install()
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
|
||||
if($config->get_int("ext_tag_history_version") < 1) {
|
||||
$database->create_table("tag_histories", "
|
||||
id SCORE_AIPK,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
user_ip SCORE_INET NOT NULL,
|
||||
tags TEXT NOT NULL,
|
||||
date_set DATETIME NOT NULL,
|
||||
INDEX(image_id),
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
");
|
||||
$config->set_int("ext_tag_history_version", 3);
|
||||
}
|
||||
|
||||
if($config->get_int("ext_tag_history_version") == 1) {
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_id INTEGER NOT NULL");
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN date_set DATETIME NOT NULL");
|
||||
$config->set_int("ext_tag_history_version", 2);
|
||||
}
|
||||
|
||||
if($config->get_int("ext_tag_history_version") == 2) {
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_ip CHAR(15) NOT NULL");
|
||||
$config->set_int("ext_tag_history_version", 3);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when a revert request is received
|
||||
*/
|
||||
private function process_revert_request($revert_id)
|
||||
{
|
||||
global $page;
|
||||
// check for the nothing case
|
||||
if($revert_id=="nothing")
|
||||
{
|
||||
// tried to set it too the same thing so ignore it (might be a bot)
|
||||
// go back to the index page with you
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link());
|
||||
return;
|
||||
}
|
||||
|
||||
$revert_id = int_escape($revert_id);
|
||||
|
||||
// lets get this revert id assuming it exists
|
||||
$result = $this->get_tag_history_from_revert($revert_id);
|
||||
|
||||
if($result==null)
|
||||
{
|
||||
// there is no history entry with that id so either the image was deleted
|
||||
// while the user was viewing the history, someone is playing with form
|
||||
// variables or we have messed up in code somewhere.
|
||||
die("Error: No tag history with specified id was found.");
|
||||
}
|
||||
|
||||
// lets get the values out of the result
|
||||
$stored_result_id = $result->fields['id'];
|
||||
$stored_image_id = $result->fields['image_id'];
|
||||
$stored_tags = $result->fields['tags'];
|
||||
|
||||
// all should be ok so we can revert by firing the SetUserTags event.
|
||||
send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags));
|
||||
|
||||
// all should be done now so redirect the user back to the image
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/$stored_image_id"));
|
||||
}
|
||||
|
||||
public function get_tag_history_from_revert($revert_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->execute("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
WHERE tag_histories.id = ?", array($revert_id));
|
||||
return ($row ? $row : null);
|
||||
}
|
||||
|
||||
public function get_tag_history_from_id($image_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
WHERE image_id = ?
|
||||
ORDER BY tag_histories.id DESC",
|
||||
array($image_id));
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
public function get_global_tag_history()
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
ORDER BY tag_histories.id DESC
|
||||
LIMIT 100");
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when an image has been deleted
|
||||
*/
|
||||
private function delete_all_tag_history($image_id)
|
||||
{
|
||||
global $database;
|
||||
$database->execute("DELETE FROM tag_histories WHERE image_id = ?", array($image_id));
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called just before an images tag are changed
|
||||
*/
|
||||
private function add_tag_history($image, $tags)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
global $user;
|
||||
|
||||
$new_tags = Tag::implode($tags);
|
||||
$old_tags = Tag::implode($image->get_tag_array());
|
||||
if($new_tags == $old_tags) return;
|
||||
|
||||
// add a history entry
|
||||
$allowed = $config->get_int("history_limit");
|
||||
if($allowed == 0) return;
|
||||
|
||||
$row = $database->execute("
|
||||
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
|
||||
VALUES (?, ?, ?, ?, now())",
|
||||
array($image->id, $new_tags, $user->id, $_SERVER['REMOTE_ADDR']));
|
||||
|
||||
// if needed remove oldest one
|
||||
if($allowed == -1) return;
|
||||
$entries = $database->db->GetOne("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
if($entries > $allowed)
|
||||
{
|
||||
// TODO: Make these queries better
|
||||
$min_id = $database->db->GetOne("SELECT MIN(id) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
$database->execute("DELETE FROM tag_histories WHERE id = ?", array($min_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Tag_History(), 40); // in before tags are actually set, so that "get current tags" works
|
||||
?>
|
||||
|
@ -1,174 +1,174 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Random Tip
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Show a random line of text in the subheader space
|
||||
* Documentation:
|
||||
* Formatting is done with HTML
|
||||
*/
|
||||
|
||||
class Tips extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
|
||||
if ($config->get_int("ext_tips_version") < 1){
|
||||
$database->create_table("tips", "
|
||||
id SCORE_AIPK,
|
||||
enable SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
image TEXT NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
INDEX (id)
|
||||
");
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO tips (enable, image, text)
|
||||
VALUES (?, ?, ?)",
|
||||
array("Y", "coins.png", "Do you like this extension? Please support us for developing new ones. <a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8235933\" target=\"_blank\">Donate through paypal</a>."));
|
||||
|
||||
$config->set_int("ext_tips_version", 1);
|
||||
log_info("tips", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
|
||||
$this->getTip();
|
||||
|
||||
if($event->page_matches("tips")) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "list":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$this->manageTips();
|
||||
$this->getAll();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "new":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "save":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$this->saveTip();
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "status":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$tipID = int_escape($event->get_arg(1));
|
||||
$this->setStatus($tipID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "delete":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$tipID = int_escape($event->get_arg(1));
|
||||
$this->deleteTip($tipID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserBlockBuilding($event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Tips Editor", make_link("tips/list"));
|
||||
}
|
||||
}
|
||||
|
||||
private function manageTips() {
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$dirPath = dir('./ext/tips/images');
|
||||
$images = array();
|
||||
while(($file = $dirPath->read()) !== false) {
|
||||
if($file[0] != ".") {
|
||||
$images[] = trim($file);
|
||||
}
|
||||
}
|
||||
$dirPath->close();
|
||||
sort($images);
|
||||
|
||||
$this->theme->manageTips($url, $images);
|
||||
}
|
||||
|
||||
private function saveTip() {
|
||||
global $database;
|
||||
|
||||
$enable = isset($_POST["enable"]) ? "Y" : "N";
|
||||
$image = html_escape($_POST["image"]);
|
||||
$text = $_POST["text"];
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO tips (enable, image, text)
|
||||
VALUES (?, ?, ?)",
|
||||
array($enable, $image, $text));
|
||||
|
||||
}
|
||||
|
||||
private function getTip() {
|
||||
global $database;
|
||||
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$tip = $database->get_row("SELECT * ".
|
||||
"FROM tips ".
|
||||
"WHERE enable = 'Y' ".
|
||||
"ORDER BY RAND() ".
|
||||
"LIMIT 1");
|
||||
|
||||
if($tip) {
|
||||
$this->theme->showTip($url, $tip);
|
||||
}
|
||||
}
|
||||
|
||||
private function getAll() {
|
||||
global $database;
|
||||
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$tips = $database->get_all("SELECT * FROM tips ORDER BY id ASC");
|
||||
|
||||
$this->theme->showAll($url, $tips);
|
||||
}
|
||||
|
||||
private function setStatus($tipID) {
|
||||
global $database;
|
||||
|
||||
$tip = $database->get_row("SELECT * FROM tips WHERE id = ? ", array($tipID));
|
||||
|
||||
if($tip['enable'] == "Y") {
|
||||
$enable = "N";
|
||||
} elseif($tip['enable'] == "N") {
|
||||
$enable = "Y";
|
||||
}
|
||||
|
||||
$database->execute("UPDATE tips SET enable = ? WHERE id = ?", array ($enable, $tipID));
|
||||
}
|
||||
|
||||
private function deleteTip($tipID) {
|
||||
global $database;
|
||||
$database->execute("DELETE FROM tips WHERE id = ?", array($tipID));
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Name: Random Tip
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Show a random line of text in the subheader space
|
||||
* Documentation:
|
||||
* Formatting is done with HTML
|
||||
*/
|
||||
|
||||
class Tips extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
|
||||
if ($config->get_int("ext_tips_version") < 1){
|
||||
$database->create_table("tips", "
|
||||
id SCORE_AIPK,
|
||||
enable SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
image TEXT NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
INDEX (id)
|
||||
");
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO tips (enable, image, text)
|
||||
VALUES (?, ?, ?)",
|
||||
array("Y", "coins.png", "Do you like this extension? Please support us for developing new ones. <a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8235933\" target=\"_blank\">Donate through paypal</a>."));
|
||||
|
||||
$config->set_int("ext_tips_version", 1);
|
||||
log_info("tips", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
|
||||
$this->getTip();
|
||||
|
||||
if($event->page_matches("tips")) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "list":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$this->manageTips();
|
||||
$this->getAll();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "new":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "save":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$this->saveTip();
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "status":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$tipID = int_escape($event->get_arg(1));
|
||||
$this->setStatus($tipID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "delete":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$tipID = int_escape($event->get_arg(1));
|
||||
$this->deleteTip($tipID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserBlockBuilding($event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Tips Editor", make_link("tips/list"));
|
||||
}
|
||||
}
|
||||
|
||||
private function manageTips() {
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$dirPath = dir('./ext/tips/images');
|
||||
$images = array();
|
||||
while(($file = $dirPath->read()) !== false) {
|
||||
if($file[0] != ".") {
|
||||
$images[] = trim($file);
|
||||
}
|
||||
}
|
||||
$dirPath->close();
|
||||
sort($images);
|
||||
|
||||
$this->theme->manageTips($url, $images);
|
||||
}
|
||||
|
||||
private function saveTip() {
|
||||
global $database;
|
||||
|
||||
$enable = isset($_POST["enable"]) ? "Y" : "N";
|
||||
$image = html_escape($_POST["image"]);
|
||||
$text = $_POST["text"];
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO tips (enable, image, text)
|
||||
VALUES (?, ?, ?)",
|
||||
array($enable, $image, $text));
|
||||
|
||||
}
|
||||
|
||||
private function getTip() {
|
||||
global $database;
|
||||
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$tip = $database->get_row("SELECT * ".
|
||||
"FROM tips ".
|
||||
"WHERE enable = 'Y' ".
|
||||
"ORDER BY RAND() ".
|
||||
"LIMIT 1");
|
||||
|
||||
if($tip) {
|
||||
$this->theme->showTip($url, $tip);
|
||||
}
|
||||
}
|
||||
|
||||
private function getAll() {
|
||||
global $database;
|
||||
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$tips = $database->get_all("SELECT * FROM tips ORDER BY id ASC");
|
||||
|
||||
$this->theme->showAll($url, $tips);
|
||||
}
|
||||
|
||||
private function setStatus($tipID) {
|
||||
global $database;
|
||||
|
||||
$tip = $database->get_row("SELECT * FROM tips WHERE id = ? ", array($tipID));
|
||||
|
||||
if($tip['enable'] == "Y") {
|
||||
$enable = "N";
|
||||
} elseif($tip['enable'] == "N") {
|
||||
$enable = "Y";
|
||||
}
|
||||
|
||||
$database->execute("UPDATE tips SET enable = ? WHERE id = ?", array ($enable, $tipID));
|
||||
}
|
||||
|
||||
private function deleteTip($tipID) {
|
||||
global $database;
|
||||
$database->execute("DELETE FROM tips WHERE id = ?", array($tipID));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,99 +1,99 @@
|
||||
<?php
|
||||
class TipsTheme extends Themelet {
|
||||
public function manageTips($url, $images) {
|
||||
global $page;
|
||||
$select = "<select name='image'><option value=''>- Select Image -</option>";
|
||||
|
||||
foreach($images as $image){
|
||||
$select .= "<option style='background-image:url(".$url.$image."); background-repeat:no-repeat; padding-left:20px;' value=\"".$image."\">".$image."</option>\n";
|
||||
}
|
||||
|
||||
$select .= "</select>";
|
||||
|
||||
$html = "
|
||||
<form action='".make_link("tips/save")."' method='POST'>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Enable:</td>
|
||||
<td><input name='enable' type='checkbox' value='Y' checked/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image:</td>
|
||||
<td>{$select}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Message:</td>
|
||||
<td><textarea name='text'></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2'><input type='submit' value='Submit' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$page->set_title("Tips List");
|
||||
$page->set_heading("Tips List");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Add Tip", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function showTip($url, $tip) {
|
||||
global $page;
|
||||
|
||||
$img = "";
|
||||
if(!empty($tip['image'])) {
|
||||
$img = "<img src=".$url.$tip['image']." /> ";
|
||||
}
|
||||
$html = "<div id='tips'>".$img.$tip['text']."</div>";
|
||||
$page->add_block(new Block(null, $html, "subheading", 10));
|
||||
}
|
||||
|
||||
public function showAll($url, $tips){
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>ID</th>".
|
||||
"<th>Enabled</th>".
|
||||
"<th>Image</th>".
|
||||
"<th>Text</th>";
|
||||
|
||||
if($user->is_admin()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>";
|
||||
|
||||
$n = 0;
|
||||
foreach ($tips as $tip)
|
||||
{
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$tip_enable = ($tip['enable'] == "Y") ? "Yes" : "No";
|
||||
$set_link = "<a href='".make_link("tips/status/".$tip['id'])."'>".$tip_enable."</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td>".$tip['id']."</td>".
|
||||
"<td>".$set_link."</td>".
|
||||
(
|
||||
empty($tip['image']) ?
|
||||
"<td></td>" :
|
||||
"<td><img src=".$url.$tip['image']." /></td>"
|
||||
).
|
||||
"<td class='left'>".$tip['text']."</td>";
|
||||
|
||||
$del_link = "<a href='".make_link("tips/delete/".$tip['id'])."'>Delete</a>";
|
||||
|
||||
if($user->is_admin()){
|
||||
$html .= "<td>".$del_link."</td>";
|
||||
}
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$page->add_block(new Block("All Tips", $html, "main", 20));
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
class TipsTheme extends Themelet {
|
||||
public function manageTips($url, $images) {
|
||||
global $page;
|
||||
$select = "<select name='image'><option value=''>- Select Image -</option>";
|
||||
|
||||
foreach($images as $image){
|
||||
$select .= "<option style='background-image:url(".$url.$image."); background-repeat:no-repeat; padding-left:20px;' value=\"".$image."\">".$image."</option>\n";
|
||||
}
|
||||
|
||||
$select .= "</select>";
|
||||
|
||||
$html = "
|
||||
<form action='".make_link("tips/save")."' method='POST'>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Enable:</td>
|
||||
<td><input name='enable' type='checkbox' value='Y' checked/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image:</td>
|
||||
<td>{$select}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Message:</td>
|
||||
<td><textarea name='text'></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2'><input type='submit' value='Submit' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$page->set_title("Tips List");
|
||||
$page->set_heading("Tips List");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Add Tip", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function showTip($url, $tip) {
|
||||
global $page;
|
||||
|
||||
$img = "";
|
||||
if(!empty($tip['image'])) {
|
||||
$img = "<img src=".$url.$tip['image']." /> ";
|
||||
}
|
||||
$html = "<div id='tips'>".$img.$tip['text']."</div>";
|
||||
$page->add_block(new Block(null, $html, "subheading", 10));
|
||||
}
|
||||
|
||||
public function showAll($url, $tips){
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>ID</th>".
|
||||
"<th>Enabled</th>".
|
||||
"<th>Image</th>".
|
||||
"<th>Text</th>";
|
||||
|
||||
if($user->is_admin()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>";
|
||||
|
||||
$n = 0;
|
||||
foreach ($tips as $tip)
|
||||
{
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$tip_enable = ($tip['enable'] == "Y") ? "Yes" : "No";
|
||||
$set_link = "<a href='".make_link("tips/status/".$tip['id'])."'>".$tip_enable."</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td>".$tip['id']."</td>".
|
||||
"<td>".$set_link."</td>".
|
||||
(
|
||||
empty($tip['image']) ?
|
||||
"<td></td>" :
|
||||
"<td><img src=".$url.$tip['image']." /></td>"
|
||||
).
|
||||
"<td class='left'>".$tip['text']."</td>";
|
||||
|
||||
$del_link = "<a href='".make_link("tips/delete/".$tip['id'])."'>Delete</a>";
|
||||
|
||||
if($user->is_admin()){
|
||||
$html .= "<td>".$del_link."</td>";
|
||||
}
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$page->add_block(new Block("All Tips", $html, "main", 20));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user