public function savePaste($bin, $paste, $syntax = 'none', $title = '')
{
$this->_connect();
-
+
$id = $this->_db->nextId('mySequence');
if (PEAR::isError($id)) {
throw new Horde_Exception_Prior($id);
/**
* Retrieves the paste from the database.
- *
+ *
* @param array $params Array of selectors to find the paste.
*
* @return array Array of paste information
}
}
+ public function getPastes($bin)
+ {
+ $query = 'SELECT paste_id, paste_uuid, paste_title, paste_syntax, '.
+ 'paste_content, paste_owner, paste_timestamp ' .
+ 'FROM pastie_pastes WHERE paste_bin = ? ' .
+ 'ORDER BY paste_timestamp DESC';
+ $values[] = 'default'; // FIXME: Horde_Share
+
+ /* Make sure we have a valid database connection. */
+ $this->_connect();
+
+ /* Log the query at a DEBUG log level. */
+ Horde::logMessage(sprintf('Pastie_Driver_Sql#getPastes(): %s', $query), 'DEBUG');
+
+ /* Execute the query. */
+ $result = $this->_db->query($query, $values);
+
+ if ($result instanceof PEAR_Error) {
+ throw new Horde_Exception_Prior($result);
+ }
+
+ $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
+ if ($row instanceof PEAR_Error) {
+ throw new Horde_Exception_Prior($row);
+ }
+
+ $pastes = array();
+ while ($row && !($row instanceof PEAR_Error)) {
+ $pastes[$row['paste_uuid']] = array(
+ 'id' => $row['paste_id'],
+ 'uuid' => $row['paste_uuid'],
+ 'bin' => $row['paste_bin'],
+ 'title' => $row['paste_title'],
+ 'syntax' => $row['paste_syntax'],
+ 'paste' => $row['paste_content'],
+ 'owner' => $row['paste_owner'],
+ 'timestamp' => new Horde_Date($row['paste_timestamp'])
+ );
+
+ /* Advance to the new row in the result set. */
+ $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
+ }
+ $result->free();
+
+ return $pastes;
+ }
+
/**
* Attempts to open a persistent connection to the SQL server.
*
}
}
+try {
+ $recent = $pastie->driver->getPastes('default'); //FIXME: Horde_Share
+} catch (Horde_Exception $e) {
+ $notification->push($e);
+}
+
+
$title = $form->getTitle();
require PASTIE_TEMPLATES . '/common-header.inc';
require PASTIE_TEMPLATES . '/menu.inc';
-$form->renderActive(null, null, $url, 'post');
+require PASTIE_TEMPLATES . '/paste.inc';
require $registry->get('templates', 'horde') . '/common-footer.inc';
--- /dev/null
+<?php
+$uuid = Horde::applicationUrl('uuid');
+?>
+<div id="recentPastes">
+<h2>Recent Pastings</h2>
+<hr>
+<?php foreach ($recent as $r) { ?>
+ <div class="recentPaste">
+ <span class="pasteTitle"><a href="<?php echo $uuid . '/' . $r['uuid']; ?>"><?php echo $r['title']; ?></a></span><br>
+ <span class="pasteAuthor"><?php echo $r['owner']; ?></span> |
+ <span class="pasteSyntax"><?php echo $r['syntax']; ?></span> |
+ <span class="pasteDate"><?php echo $r['timestamp']; ?></span>
+ </div>
+ <hr>
+<?php } ?>
+</div>
\ No newline at end of file