Example #1
0
                $result .= '<tr><th>Date</th><th>Subject</th><th>Parts</th><th>Size</th></tr>' . "\n";
                $articles = Article::Find(null, 'SELECT * FROM `articles` WHERE `postid` = ' . $post->id . ' ORDER BY `subject` ASC');
                if (!is_array($articles)) {
                    $articles = array($articles);
                }
                foreach ($articles as $article) {
                    $result .= '<tr>' . "\n";
                    $result .= '<td class="date">' . gmdate('Y-m-d H:i', $article->post_date) . '</td>' . "\n";
                    $result .= '<td class="subject">' . SafeHTML($article->subject) . '</td>';
                    if ($article->parts_found != $article->parts_total) {
                        $result .= '<td class="parts"><span class="warning">' . SafeHTML($article->parts_found) . ' / ' . SafeHTML($article->parts_total) . '</span></td>';
                    } else {
                        $result .= '<td class="parts">' . SafeHTML($article->parts_found) . ' / ' . SafeHTML($article->parts_total) . '</span></td>';
                    }
                    $result .= '<td class="size">' . FormatSize($article->size, 2) . '</td>';
                    $result .= '</tr>' . "\n";
                }
                $result .= '</table>' . "\n";
            } catch (ActiveRecord_NotFoundException $e) {
                die('<b>Error</b>: database problem - post has no associated articles.');
            }
            $template->body = $result;
            $template->Display('layout_ajax');
        }
    }
    // Display
    $controller = new IndexController();
    echo $controller->Run();
} catch (Exception $e) {
    echo $e->getMessage();
}