/** * Display a DB item (in mode=show). * * @param int $id The ID of the item to show * @param string $display Can be 'compact' or 'default' * @return string|null HTML of the single item */ function showDB($id, $display = 'default') { global $pdo; $sql = "SELECT items.*,\n items_types.bgcolor,\n items_types.name\n FROM items\n LEFT JOIN items_types ON (items.type = items_types.id)\n WHERE items.id = :id"; $req = $pdo->prepare($sql); $req->execute(array('id' => $id)); $item = $req->fetch(); if ($display === 'compact') { // COMPACT MODE // ?> <section class='item_compact' style='border-left: 6px solid #<?php echo $item['bgcolor']; ?> '> <a href='database.php?mode=view&id=<?php echo $item['id']; ?> '> <span class='date date_compact'><?php echo $item['date']; ?> </span> <h4 style='padding-left:10px;border-right:1px dotted #ccd;color:#<?php echo $item['bgcolor']; ?> '><?php echo $item['name']; ?> </h4> <span style='margin-left:7px'><?php echo stripslashes($item['title']); ?> </span> <?php // STAR RATING read only show_stars($item['rating']); echo "</a></section>"; } else { // NOT COMPACT echo "<section class='item' style='border-left: 6px solid #" . $item['bgcolor'] . "'>"; echo "<a href='database.php?mode=view&id=" . $item['id'] . "'>"; // show attached if there is a file attached if (has_attachement($item['id'], 'items')) { echo "<img style='clear:both' class='align_right' src='img/attached.png' alt='file attached' />"; } // STARS show_stars($item['rating']); echo "<p class='title'>"; // show lock if item is locked on viewDB if ($item['locked'] == 1) { echo "<img style='padding-bottom:3px;' src='img/lock-blue.png' alt='lock' />"; } // TITLE echo stripslashes($item['title']) . "</p></a>"; // ITEM TYPE echo "<span style='text-transform:uppercase;font-size:80%;padding-left:20px;color:#" . $item['bgcolor'] . "'>" . $item['name'] . " </span>"; // DATE echo "<span class='date' style='padding:0 5px;'><img class='image' src='img/calendar.png' /> " . Tools::formatDate($item['date']) . "</span> "; // TAGS echo show_tags($id, 'items_tags'); echo "</section>"; } }
function showDB($id, $display) { // Show unique DB item global $bdd; // SQL to get everything from selected id $sql = "SELECT * FROM items WHERE id = :id"; $req = $bdd->prepare($sql); $req->execute(array('id' => $id)); $final_query = $req->fetch(); if ($display === 'compact') { // COMPACT MODE // ?> <section class='item'> <h4 style='color:#<?php echo get_item_info_from_id($final_query['type'], 'bgcolor'); ?> '><?php echo get_item_info_from_id($final_query['type'], 'name'); ?> </h4> <span class='date date_compact'><?php echo $final_query['date']; ?> </span> <span><?php echo stripslashes($final_query['title']); // view link echo "<a href='database.php?mode=view&id=" . $final_query['id'] . "'>\n <img class='align_right' style='margin-left:5px;' src='img/view_compact.png' alt='view' title='view item' /></a>"; // STAR RATING read only show_stars($final_query['rating']); echo "</section>"; } else { // NOT COMPACT echo "<section class='item'>"; echo "<h4 style='color:#" . get_item_info_from_id($final_query['type'], 'bgcolor') . "'>" . get_item_info_from_id($final_query['type'], 'name') . " </h4>"; // TAGS echo show_tags($id, 'items_tags'); // view link echo "<a href='database.php?mode=view&id=" . $final_query['id'] . "'>\n <img class='align_right' style='margin-left:5px;' src='img/view.png' alt='view' title='view item' /></a>"; // STARS show_stars($final_query['rating']); // show attached if there is a file attached if (has_attachement($final_query['id'])) { echo "<img class='align_right' src='themes/" . $_SESSION['prefs']['theme'] . "/img/attached_file.png' alt='file attached' />"; } echo "<p class='title'>" . stripslashes($final_query['title']) . "</p>"; echo "</section>"; } }