--- quotes.module 2007-02-14 09:28:36.000000000 -0500
+++ quotes_nancy.module 2007-07-05 11:13:25.109375000 -0400
@@ -158,6 +158,12 @@
'#rows' => 3,
'#default_value' => $node->quotes_author
);
+ $form['quotes_data']['quotes_citation'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Citation'),
+ '#rows' => 3,
+ '#default_value' => $node->quotes_citation
+ );
}
else {
if (!user_access('import quotes')) {
@@ -237,6 +243,7 @@
$temp->body = $quote->body;
$temp->teaser = '';
$temp->quotes_author = $quote->quotes_author;
+ $temp->quotes_citation = $quote->quotes_citation;
drupal_execute('quotes_node_form', (array)$temp, array('type' => 'quotes'));
@@ -256,7 +263,7 @@
* Implementation of hook_load().
*/
function quotes_load($node) {
- return db_fetch_object(db_query("SELECT q.author AS quotes_author, q.promote AS quotes_promote FROM {quotes} q WHERE q.vid = %d", $node->vid));
+ return db_fetch_object(db_query("SELECT q.author AS quotes_author, q.citation AS quotes_citation, q.promote AS quotes_promote FROM {quotes} q WHERE q.vid = %d", $node->vid));
}
/**
@@ -265,7 +272,7 @@
* variable in the node title.
*/
function quotes_insert($node) {
- db_query("INSERT INTO {quotes} (nid, vid, author, promote) VALUES (%d, %d, '%s', %d)", $node->nid, $node->vid, $node->quotes_author, $node->quotes_promote);
+ db_query("INSERT INTO {quotes} (nid, vid, author, citation, promote) VALUES (%d, %d, '%s', '%s', %d)", $node->nid, $node->vid, $node->quotes_author, $node->quotes_citation, $node->quotes_promote);
// replace %id variable in title
if (strpos($node->title, '%id') !== FALSE) {
@@ -284,7 +291,7 @@
quotes_insert($node);
}
else {
- db_query("UPDATE {quotes} SET author = '%s', promote = %d WHERE nid = %d AND vid = %d", $node->quotes_author, $node->quotes_promote, $node->nid, $node->vid);
+ db_query("UPDATE {quotes} SET author = '%s', citation = '%s', promote = %d WHERE nid = %d AND vid = %d", $node->quotes_author, $node->quotes_citation, $node->quotes_promote, $node->nid, $node->vid);
}
}
@@ -347,7 +354,13 @@
$links['quotes_usernames_quotes'] = array(
'title' => t("!name's quotes", array('!name' => $name)),
'href' => "quotes/$node->uid",
- 'attributes' => array('title' => t("View !name's quotes.", array('!name' => $name))));
+ 'attributes' => array('title' => t("View !name's quotes.", array('!name' => $name))),
+ );
+ $links['quotes_addanother'] = array(
+ 'title' => t("Add another quote"),
+ 'href' => "node/add/quotes",
+ 'attributes' => array('title' => t("Add another quote")),
+ );
}
return $links;
@@ -608,8 +621,8 @@
Tab-separated quotes should appear one quote per line in the
format quote<tab>author. The author is optional; however, the
- tab is still required. To import quotes or authors with more than
+ green;">author. The author and citation are optional; however, the
+ tab is still required. To import quotes, authors, or citations with more than
one line, escape the embedded newlines with a backslash.
Examples:
@@ -719,15 +732,11 @@
$author = ($node->quotes_author ? check_markup(variable_get('quotes_leader', '—') . " $node->quotes_author", $node->format, ($user->uid == $node->uid)) : '');
- return "
-
- $node->body
-
-" . ($author ?
-"
- $author
-
-" : '');
+ $citation = ($node->quotes_citation ? check_markup("". $node->quotes_citation ."", $node->format, ($user->uid == $node->uid)) : '');
+
+ return ''. $node->body .'
'
+ . ($author ? ''. $author . '
' : '')
+ . ($citation ? ''. $citation .'
' : '');
}
/**
@@ -751,13 +760,13 @@
drupal_set_title(t("!name's quotes", array('!name' => ($uid ? $user->name : variable_get('anonymous', t('Anonymous'))))));
$url = url("quotes/$uid/feed");
- $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created, nr.title, q.author FROM {node} n INNER JOIN {node_revisions} nr ON nr.vid = n.vid INNER JOIN {quotes} q ON q.vid = n.vid WHERE n.status = 1 AND n.type = 'quotes' AND n.uid = %d ORDER BY n.sticky DESC, n.created DESC"), $limit, 0, NULL, $uid);
+ $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created, nr.title, q.author, q.citation FROM {node} n INNER JOIN {node_revisions} nr ON nr.vid = n.vid INNER JOIN {quotes} q ON q.vid = n.vid WHERE n.status = 1 AND n.type = 'quotes' AND n.uid = %d ORDER BY n.sticky DESC, n.created DESC"), $limit, 0, NULL, $uid);
}
else {
drupal_set_title('quotes');
$url = url('quotes/feed');
- $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created, nr.title, q.author FROM {node} n INNER JOIN {node_revisions} nr ON nr.vid = n.vid INNER JOIN {quotes} q ON q.vid = n.vid WHERE n.status = 1 AND n.type = 'quotes' ORDER BY n.sticky DESC, n.created DESC"), $limit);
+ $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created, nr.title, q.author, q.citation FROM {node} n INNER JOIN {node_revisions} nr ON nr.vid = n.vid INNER JOIN {quotes} q ON q.vid = n.vid WHERE n.status = 1 AND n.type = 'quotes' ORDER BY n.sticky DESC, n.created DESC"), $limit);
}
$output = '';
@@ -930,7 +939,7 @@
*
* @return
* An array containing the parsed quotes as objects with properties
- * body, quotes_author, and format.
+ * body, quotes_author, quotes_citation, and format.
*/
function _quotes_parse_import($node, $set_errors = FALSE) {
$quotes = array();
@@ -939,15 +948,14 @@
foreach (explode("\r", str_replace("\\\r", "\n", preg_replace('<(?:\r\n?|\n)>', "\r", trim($node->body)))) as $quote) {
$quote = explode("\t", $quote);
- if ((count($quote) != 2) || !trim($quote[0])) {
+ if ((count($quote) < 2) || !trim($quote[0])) {
if ($set_errors) {
form_set_error('body', t('Parse error on quote !num.', array('!num' => count($quotes) + 1)));
}
-
break;
}
- $quotes[] = (object)array('body' => trim($quote[0]), 'quotes_author' => $quote[1], 'format' => $node->format);
+ $quotes[] = (object)array('body' => trim($quote[0]), 'quotes_author' => $quote[1], 'quotes_citation' => $quote[2], 'format' => $node->format);
}
}
elseif ($node->quotes_format == 'fortune') {
@@ -961,7 +969,7 @@
break;
}
- $quotes[] = (object)array('body' => trim($matches[1]), 'quotes_author' => $matches[2], 'format' => $node->format);
+ $quotes[] = (object)array('body' => trim($matches[1]), 'quotes_author' => $matches[2], 'quotes_citation' => NULL, 'format' => $node->format);
}
else {
if (!trim($quote)) {
@@ -1000,7 +1008,7 @@
'#type' => 'textfield',
'#title' => t('Author leader'),
'#default_value' => variable_get('quotes_leader', '—'),
- '#description' => t('The text placed before the author attribution (i.e. "—" for an em-dash or "•" for a bullet).')
+ '#description' => t('The text placed before the author attribution (e.g. "—" for an em-dash or "•" for a bullet).')
);
return system_settings_form($form);
--- quotes.install 2007-02-19 13:33:52.000000000 -0500
+++ quotes_nancy.install 2007-07-05 11:39:22.921875000 -0400
@@ -22,6 +22,7 @@
nid INTEGER NOT NULL,
vid INTEGER NOT NULL PRIMARY KEY,
author VARCHAR(255) NOT NULL,
+ citation VARCHAR(255),
promote INTEGER NOT NULL
) /*!40100 DEFAULT CHARACTER SET utf8 */
');
@@ -55,6 +56,7 @@
function quotes_uninstall() {
db_query('DROP TABLE {quotes}');
db_query('DROP TABLE {quotes_blocks}');
+ db_query("DELETE FROM {blocks} WHERE module='quotes'");
if ($_GLOBALS['db_type'] == 'pgsql') {
db_query('DROP SEQUENCE {quotes}_bid_seq');
@@ -133,4 +135,15 @@
return $items;
}
-?>
\ No newline at end of file
+/**
+ * Add citation column to quotes table
+ */
+function quotes_update_5() {
+ global $db_type;
+
+ $items = array();
+
+ $items[] = update_sql('ALTER TABLE {quotes} ADD citation VARCHAR(255)');
+
+ return $items;
+}
\ No newline at end of file