- Menu and code improvements by JonBob.

4.5.x
Dries Buytaert 2004-05-08 07:17:47 +00:00
parent 7bf77b6a5e
commit 3de9d33e67
9 changed files with 360 additions and 311 deletions

View File

@ -25,7 +25,7 @@ define('MENU_FOUND', 2);
* Register a menu item with the menu system.
*
* @ingroup menu
* @param $path Location then menu item refers to.
* @param $path Location the menu item refers to. Do not add a trailing slash.
* @param $title The title of the menu item to show in the rendered menu.
* @param $callback
* - string - The function to call when this is the active menu item.
@ -394,8 +394,23 @@ function menu_build_visible_tree($pid = 0) {
$children = array_merge($children, menu_build_visible_tree($mid));
}
}
if ((($parent['visibility'] == MENU_SHOW) ||
($parent['visibility'] == MENU_HIDE_NOCHILD && count($children) > 1)) && $parent['callback'] !== MENU_DENIED) {
$visible = ($parent['visibility'] == MENU_SHOW) ||
($parent['visibility'] == MENU_HIDE_NOCHILD && count($children) > 0);
if ($parent['callback'] === MENU_FALLTHROUGH) {
// Follow the path up to find the actual callback.
$path = $parent['path'];
while ($path && (!$_menu['path index'][$path] || $_menu['items'][$_menu['path index'][$path]]['callback'] === MENU_FALLTHROUGH)) {
$path = substr($path, 0, strrpos($path, '/'));
}
$callback_mid = $_menu['path index'][$path];
$allowed = $_menu['items'][$callback_mid]['callback'] !== MENU_DENIED;
}
else {
$allowed = $parent['callback'] !== MENU_DENIED;
}
if ($visible && $allowed) {
$_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children);
foreach ($children as $mid) {
$_menu['visible'][$mid]['pid'] = $pid;

View File

@ -99,7 +99,7 @@ function archive_calendar($original = 0) {
if ($weekstart) {
$days = array_merge(array_slice($days, $weekstart), array_slice($days, 0, $weekstart));
}
foreach ($days as $name => $fullname) {
$output .= " <th abbr=\"". $fullname ."\">". $name . "</th>\n";
}

View File

@ -99,7 +99,7 @@ function archive_calendar($original = 0) {
if ($weekstart) {
$days = array_merge(array_slice($days, $weekstart), array_slice($days, 0, $weekstart));
}
foreach ($days as $name => $fullname) {
$output .= " <th abbr=\"". $fullname ."\">". $name . "</th>\n";
}

View File

@ -1,150 +1,198 @@
<?php
// $Id$
/**
* Implementation of hook_settings().
*/
function blog_settings() {
$output = form_textarea(t("Explanation or submission guidelines"), "blog_help", variable_get("blog_help", ""), 70, 4, t("This text is displayed at the top of the blog submission form. It's useful for helping or instructing your users."));
$output .= form_select(t("Minimum number of words in a blog entry"), "minimum_blog_size", variable_get("minimum_blog_size", 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t("The minimum number of words a personal blog entry should contain. This is useful to rule out submissions that do not meet the site's standards, such as short test posts."));
$output = form_textarea(t('Explanation or submission guidelines'), 'blog_help', variable_get('blog_help', ''), 70, 4, t("This text is displayed at the top of the blog submission form. It's useful for helping or instructing your users."));
$output .= form_select(t('Minimum number of words in a blog entry'), 'minimum_blog_size', variable_get('minimum_blog_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t("The minimum number of words a personal blog entry should contain. This is useful to rule out submissions that do not meet the site's standards, such as short test posts."));
return $output;
}
/**
* Implementation of hook_node_name().
*/
function blog_node_name($node) {
return t("personal blog entry");
return t('personal blog entry');
}
/**
* Implementation of hook_perm().
*/
function blog_perm() {
return array("maintain personal blog");
return array('maintain personal blog');
}
/**
* Implementation of hook_access().
*/
function blog_access($op, $node) {
global $user;
if ($op == "view") {
if ($op == 'view') {
return $node->status;
}
if ($op == "create") {
return user_access("maintain personal blog") && $user->uid;
if ($op == 'create') {
return user_access('maintain personal blog') && $user->uid;
}
if ($op == "update") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
if ($op == 'update') {
return user_access('maintain personal blog') && ($user->uid == $node->uid);
}
if ($op == "delete") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
if ($op == 'delete') {
return user_access('maintain personal blog') && ($user->uid == $node->uid);
}
}
/**
* Implementation of hook_user().
*/
function blog_user($type, &$edit, &$user) {
if ($type == 'view' && user_access("maintain personal blog", $user)) {
return array(t('History') => form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name))))));
if ($type == 'view' && user_access('maintain personal blog', $user)) {
return array(t('History') => form_item(t('Blog'), l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name))))));
}
}
/**
* Implementation of hook_help().
*/
function blog_help($section) {
$output ="";
switch ($section) {
case 'admin/help#blog':
$output .= t("
return t("
<p>Drupal's blog module allows registered users to maintain an online weblog (commonly known as a blog), often referred to as an online journal or diary. These can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.</p>
<p>Blogs are made up of individual entries (nodes) that are timestamped and are typically viewed by day as you would a diary. Blogs often contain links to things you've seen and/or agree/disagree with. A typical example of a long term blog can be seen at %scripting-com.</p>
<p>The blog module adds a \"user blogs\" navigation link to the site, which takes any visitor to a page that displays the most recent blog entries from all the users on the site. Personal user menus gain a \"create a blog entry\" link (which takes you to a submission form) and a \"view personal blog\" link (which displays your blog entries as other people will see them). On the bottom of each of your own blog entries, there is an \"edit this blog entry\" link that lets you edit or delete that entry.</p>
<p>If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link <strong>(b)</strong> next to each news item in its lists. Click on this and you will be taken to the blog submission form, with the title, a link to the item, and a link to the source into the body text already in the text box, ready for you to add your explanation. This actively encourages people to add blog entries about things they see and hear elsewhere in the Drupal site and from your syndicated partner sites.</p>", array("%scripting-com" => "<a href=\"http://www.scripting.com/\">http://www.scripting.com/</a>"));
break;
<p>If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link <strong>(b)</strong> next to each news item in its lists. Click on this and you will be taken to the blog submission form, with the title, a link to the item, and a link to the source into the body text already in the text box, ready for you to add your explanation. This actively encourages people to add blog entries about things they see and hear elsewhere in the Drupal site and from your syndicated partner sites.</p>", array('%scripting-com' => '<a href="http://www.scripting.com/">http://www.scripting.com/</a>'));
case 'admin/system/modules#description':
$output .= t("Enables keeping a blog or easily and regularly updated web page.");
break;
return t('Enables keeping a blog or easily and regularly updated web page.');
case 'admin/system/modules/blog':
$output .= t("A weblog is a running journal of a user's ideas. Enter the minimum word count for a single entry, and the text displayed on the entry submission form");
break;
return t("A weblog is a running journal of a user's ideas. Enter the minimum word count for a single entry, and the text displayed on the entry submission form");
case 'node/add/blog':
$output = variable_get('blog_help', '');
break;
return variable_get('blog_help', '');
case 'node/add#blog':
$output = t("A blog is a regularly updated journal made up of individual entries, often called posts, that are time stamped and typically arranged by the day, with the newest on top (a diary is the reverse). They tend to be quite personal, often containing links to things you've seen, or to editorials that you find interesting. Some blogs also contain original material written solely for the blog. Since a Blog is personal, you and only you have full control over what you publish. The most interesting blog entries or those blog entries that fit the site's topic well might get promoted to the front page by the community or by users with the access do this.");
break;
return t("A blog is a regularly updated journal made up of individual entries, often called posts, that are time stamped and typically arranged by the day, with the newest on top (a diary is the reverse). They tend to be quite personal, often containing links to things you've seen, or to editorials that you find interesting. Some blogs also contain original material written solely for the blog. Since a Blog is personal, you and only you have full control over what you publish. The most interesting blog entries or those blog entries that fit the site's topic well might get promoted to the front page by the community or by users with the access do this.");
}
return $output;
}
/**
* Menu callback. Displays an RSS feed containing recent blog entries.
*/
function blog_feed($uid = 0) {
if ($uid) {
blog_feed_user($uid);
}
else {
blog_feed_last();
}
}
/**
* Displays an RSS feed containing recent blog entries of a given user.
*/
function blog_feed_user($uid = 0) {
global $user;
if ($uid) {
$account = user_load(array("uid" => $uid, "status" => 1));
$account = user_load(array('uid' => $uid, 'status' => 1));
}
else {
$account = $user;
}
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name ."'s blog";
$channel["link"] = url("blog/view/$uid", NULL, NULL, TRUE);
$channel["description"] = $term->description;
$channel['title'] = $account->name ."'s blog";
$channel['link'] = url("blog/view/$uid", NULL, NULL, TRUE);
$channel['description'] = $term->description;
node_feed($result, $channel);
}
/**
* Displays an RSS feed containing recent blog entries of all users.
*/
function blog_feed_last() {
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15);
$channel["title"] = variable_get("site_name", "drupal") ." blogs";
$channel["link"] = url("blog");
$channel["description"] = $term->description;
$channel['title'] = variable_get('site_name', 'drupal') .' blogs';
$channel['link'] = url('blog');
$channel['description'] = $term->description;
node_feed($result, $channel);
}
function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? "uid" : "name") => $uid, "status" => 1));
$title = t("%name's blog", array("%name" => $account->name));
$output = "";
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
/**
* Menu callback. Displays a Drupal page containing recent blog entries.
*/
function blog_page($uid = 0) {
if ($uid) {
blog_page_user($uid);
}
$output .= theme('pager', NULL, variable_get("default_nodes_main", 10));
else {
blog_page_last();
}
}
/**
* Displays a Drupal page containing recent blog entries of a given user.
*/
function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1));
$title = t("%name's blog", array('%name' => $account->name));
$output = '';
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get('default_nodes_main', 10));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url("blog/feed/$account->uid"));
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/feed/$account->uid") .'" />');
print theme("page", $output, $title);
print theme('page', $output, $title);
}
/**
* Displays a Drupal page containing recent blog entries of all users.
*/
function blog_page_last() {
global $user;
$output = "";
$output = '';
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get('default_nodes_main', 10));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
$output .= theme('pager', NULL, variable_get("default_nodes_main", 10));
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url('blog/feed'));
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - blogs" href="'. url('blog/feed') .'" />');
print theme("page", $output);
print theme('page', $output);
}
/**
* Implementation of hook_validate().
*
* Ensures the blog entry is of adequate length.
*/
function blog_validate(&$node) {
/*
** Validate the size of the blog:
*/
if (isset($node->body) && count(explode(" ", $node->body)) < variable_get("minimum_blog_size", 0)) {
$error["body"] = theme("error", t("The body of your blog is too short."));
if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_blog_size', 0)) {
$error['body'] = theme('error', t('The body of your blog is too short.'));
}
return $error;
}
/**
* Implementation of hook_form().
*/
function blog_form(&$node, &$error) {
global $nid;
$iid = $_GET["iid"];
$iid = $_GET['iid'];
if (empty($node->body)) {
/*
@ -152,63 +200,48 @@ function blog_form(&$node, &$error) {
** database and quote it in the blog:
*/
if ($nid && $blog = node_load(array("nid" => $nid))) {
$node->body = "<i>". $blog->body ."</i> [". l($blog->name, "node/view/$nid") ."]";
if ($nid && $blog = node_load(array('nid' => $nid))) {
$node->body = '<i>'. $blog->body .'</i> ['. l($blog->name, "node/view/$nid") .']';
}
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM {item} i, {feed} f WHERE i.iid = %d AND i.fid = f.fid", $iid))) {
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {item} i, {feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
$node->title = $item->title;
$node->body = "<a href=\"$item->link\">$item->title</a> - <i>". check_output($item->description) ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
}
}
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("blog", $node));
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('blog', $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : filter_tips_short());
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, $error['body'] ? $error['body'] : filter_tips_short());
return $output;
}
function blog_page() {
switch (arg(1)) {
case "feed":
if (arg(2)) {
blog_feed_user(arg(2));
}
else {
blog_feed_last();
}
break;
default:
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
}
}
/**
* Implementation of hook_content().
*/
function blog_content($node, $main = 0) {
return node_prepare($node, $main);
}
/**
* Implementation of hook_view().
*/
function blog_view($node, $main = 0, $page = 0) {
if ($page) {
// Breadcrumb navigation
$breadcrumb[] = l(t("Home"), "");
$breadcrumb[] = l(t("blogs"), "blog");
$breadcrumb[] = l(t("%name's blog", array("%name" => $node->name)), "blog/$node->uid");
$breadcrumb[] = l(t('Home'), '');
$breadcrumb[] = l(t('blogs'), 'blog');
$breadcrumb[] = l(t("%name's blog", array('%name' => $node->name)), "blog/$node->uid");
// set the breadcrumb
drupal_set_breadcrumb($breadcrumb);
}
// prepare the node content
$node = blog_content($node, $main);
// print the node
return theme("node", $node, $main, $page);
return theme('node', $node, $main, $page);
}
/**
@ -220,9 +253,10 @@ function blog_link($type, $node = 0, $main) {
$links = array();
if ($type == 'system') {
menu('node/add/blog', t('blog entry'), user_access('maintain personal blog') ? 'node_page' : MENU_DENIED, 0);
menu('node/add/blog', t('blog entry'), user_access('maintain personal blog') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
menu('blog/'. $user->uid, t('my blog'), user_access('maintain personal blog') ? 'blog_page' : MENU_DENIED, 1, MENU_SHOW, MENU_LOCKED);
menu('blog', t('blogs'), user_access('access content') ? 'blog_page' : MENU_DENIED, 0, MENU_HIDE);
menu('blog/feed', t('RSS feed'), user_access('access content') ? 'blog_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
}
if ($type == 'page' && user_access('access content')) {
@ -241,17 +275,22 @@ function blog_link($type, $node = 0, $main) {
return $links;
}
function blog_block($op = "list", $delta = 0) {
/**
* Implementation of hook_block().
*
* Displays the most recent 10 blog titles.
*/
function blog_block($op = 'list', $delta = 0) {
global $user;
if ($op == "list") {
$block[0]["info"] = t("Blogs");
if ($op == 'list') {
$block[0]['info'] = t('Blogs');
return $block;
}
else {
if (user_access("access content")) {
$block["content"] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] .= "<div class=\"more-link\">". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."</div>";
$block["subject"] = t("Blogs");
if (user_access('access content')) {
$block['content'] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block['content'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>';
$block['subject'] = t('Blogs');
}
return $block;
}

View File

@ -1,150 +1,198 @@
<?php
// $Id$
/**
* Implementation of hook_settings().
*/
function blog_settings() {
$output = form_textarea(t("Explanation or submission guidelines"), "blog_help", variable_get("blog_help", ""), 70, 4, t("This text is displayed at the top of the blog submission form. It's useful for helping or instructing your users."));
$output .= form_select(t("Minimum number of words in a blog entry"), "minimum_blog_size", variable_get("minimum_blog_size", 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t("The minimum number of words a personal blog entry should contain. This is useful to rule out submissions that do not meet the site's standards, such as short test posts."));
$output = form_textarea(t('Explanation or submission guidelines'), 'blog_help', variable_get('blog_help', ''), 70, 4, t("This text is displayed at the top of the blog submission form. It's useful for helping or instructing your users."));
$output .= form_select(t('Minimum number of words in a blog entry'), 'minimum_blog_size', variable_get('minimum_blog_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t("The minimum number of words a personal blog entry should contain. This is useful to rule out submissions that do not meet the site's standards, such as short test posts."));
return $output;
}
/**
* Implementation of hook_node_name().
*/
function blog_node_name($node) {
return t("personal blog entry");
return t('personal blog entry');
}
/**
* Implementation of hook_perm().
*/
function blog_perm() {
return array("maintain personal blog");
return array('maintain personal blog');
}
/**
* Implementation of hook_access().
*/
function blog_access($op, $node) {
global $user;
if ($op == "view") {
if ($op == 'view') {
return $node->status;
}
if ($op == "create") {
return user_access("maintain personal blog") && $user->uid;
if ($op == 'create') {
return user_access('maintain personal blog') && $user->uid;
}
if ($op == "update") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
if ($op == 'update') {
return user_access('maintain personal blog') && ($user->uid == $node->uid);
}
if ($op == "delete") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
if ($op == 'delete') {
return user_access('maintain personal blog') && ($user->uid == $node->uid);
}
}
/**
* Implementation of hook_user().
*/
function blog_user($type, &$edit, &$user) {
if ($type == 'view' && user_access("maintain personal blog", $user)) {
return array(t('History') => form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name))))));
if ($type == 'view' && user_access('maintain personal blog', $user)) {
return array(t('History') => form_item(t('Blog'), l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name))))));
}
}
/**
* Implementation of hook_help().
*/
function blog_help($section) {
$output ="";
switch ($section) {
case 'admin/help#blog':
$output .= t("
return t("
<p>Drupal's blog module allows registered users to maintain an online weblog (commonly known as a blog), often referred to as an online journal or diary. These can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.</p>
<p>Blogs are made up of individual entries (nodes) that are timestamped and are typically viewed by day as you would a diary. Blogs often contain links to things you've seen and/or agree/disagree with. A typical example of a long term blog can be seen at %scripting-com.</p>
<p>The blog module adds a \"user blogs\" navigation link to the site, which takes any visitor to a page that displays the most recent blog entries from all the users on the site. Personal user menus gain a \"create a blog entry\" link (which takes you to a submission form) and a \"view personal blog\" link (which displays your blog entries as other people will see them). On the bottom of each of your own blog entries, there is an \"edit this blog entry\" link that lets you edit or delete that entry.</p>
<p>If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link <strong>(b)</strong> next to each news item in its lists. Click on this and you will be taken to the blog submission form, with the title, a link to the item, and a link to the source into the body text already in the text box, ready for you to add your explanation. This actively encourages people to add blog entries about things they see and hear elsewhere in the Drupal site and from your syndicated partner sites.</p>", array("%scripting-com" => "<a href=\"http://www.scripting.com/\">http://www.scripting.com/</a>"));
break;
<p>If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link <strong>(b)</strong> next to each news item in its lists. Click on this and you will be taken to the blog submission form, with the title, a link to the item, and a link to the source into the body text already in the text box, ready for you to add your explanation. This actively encourages people to add blog entries about things they see and hear elsewhere in the Drupal site and from your syndicated partner sites.</p>", array('%scripting-com' => '<a href="http://www.scripting.com/">http://www.scripting.com/</a>'));
case 'admin/system/modules#description':
$output .= t("Enables keeping a blog or easily and regularly updated web page.");
break;
return t('Enables keeping a blog or easily and regularly updated web page.');
case 'admin/system/modules/blog':
$output .= t("A weblog is a running journal of a user's ideas. Enter the minimum word count for a single entry, and the text displayed on the entry submission form");
break;
return t("A weblog is a running journal of a user's ideas. Enter the minimum word count for a single entry, and the text displayed on the entry submission form");
case 'node/add/blog':
$output = variable_get('blog_help', '');
break;
return variable_get('blog_help', '');
case 'node/add#blog':
$output = t("A blog is a regularly updated journal made up of individual entries, often called posts, that are time stamped and typically arranged by the day, with the newest on top (a diary is the reverse). They tend to be quite personal, often containing links to things you've seen, or to editorials that you find interesting. Some blogs also contain original material written solely for the blog. Since a Blog is personal, you and only you have full control over what you publish. The most interesting blog entries or those blog entries that fit the site's topic well might get promoted to the front page by the community or by users with the access do this.");
break;
return t("A blog is a regularly updated journal made up of individual entries, often called posts, that are time stamped and typically arranged by the day, with the newest on top (a diary is the reverse). They tend to be quite personal, often containing links to things you've seen, or to editorials that you find interesting. Some blogs also contain original material written solely for the blog. Since a Blog is personal, you and only you have full control over what you publish. The most interesting blog entries or those blog entries that fit the site's topic well might get promoted to the front page by the community or by users with the access do this.");
}
return $output;
}
/**
* Menu callback. Displays an RSS feed containing recent blog entries.
*/
function blog_feed($uid = 0) {
if ($uid) {
blog_feed_user($uid);
}
else {
blog_feed_last();
}
}
/**
* Displays an RSS feed containing recent blog entries of a given user.
*/
function blog_feed_user($uid = 0) {
global $user;
if ($uid) {
$account = user_load(array("uid" => $uid, "status" => 1));
$account = user_load(array('uid' => $uid, 'status' => 1));
}
else {
$account = $user;
}
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name ."'s blog";
$channel["link"] = url("blog/view/$uid", NULL, NULL, TRUE);
$channel["description"] = $term->description;
$channel['title'] = $account->name ."'s blog";
$channel['link'] = url("blog/view/$uid", NULL, NULL, TRUE);
$channel['description'] = $term->description;
node_feed($result, $channel);
}
/**
* Displays an RSS feed containing recent blog entries of all users.
*/
function blog_feed_last() {
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15);
$channel["title"] = variable_get("site_name", "drupal") ." blogs";
$channel["link"] = url("blog");
$channel["description"] = $term->description;
$channel['title'] = variable_get('site_name', 'drupal') .' blogs';
$channel['link'] = url('blog');
$channel['description'] = $term->description;
node_feed($result, $channel);
}
function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? "uid" : "name") => $uid, "status" => 1));
$title = t("%name's blog", array("%name" => $account->name));
$output = "";
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
/**
* Menu callback. Displays a Drupal page containing recent blog entries.
*/
function blog_page($uid = 0) {
if ($uid) {
blog_page_user($uid);
}
$output .= theme('pager', NULL, variable_get("default_nodes_main", 10));
else {
blog_page_last();
}
}
/**
* Displays a Drupal page containing recent blog entries of a given user.
*/
function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1));
$title = t("%name's blog", array('%name' => $account->name));
$output = '';
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get('default_nodes_main', 10));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url("blog/feed/$account->uid"));
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/feed/$account->uid") .'" />');
print theme("page", $output, $title);
print theme('page', $output, $title);
}
/**
* Displays a Drupal page containing recent blog entries of all users.
*/
function blog_page_last() {
global $user;
$output = "";
$output = '';
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get('default_nodes_main', 10));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
$output .= theme('pager', NULL, variable_get("default_nodes_main", 10));
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url('blog/feed'));
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - blogs" href="'. url('blog/feed') .'" />');
print theme("page", $output);
print theme('page', $output);
}
/**
* Implementation of hook_validate().
*
* Ensures the blog entry is of adequate length.
*/
function blog_validate(&$node) {
/*
** Validate the size of the blog:
*/
if (isset($node->body) && count(explode(" ", $node->body)) < variable_get("minimum_blog_size", 0)) {
$error["body"] = theme("error", t("The body of your blog is too short."));
if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_blog_size', 0)) {
$error['body'] = theme('error', t('The body of your blog is too short.'));
}
return $error;
}
/**
* Implementation of hook_form().
*/
function blog_form(&$node, &$error) {
global $nid;
$iid = $_GET["iid"];
$iid = $_GET['iid'];
if (empty($node->body)) {
/*
@ -152,63 +200,48 @@ function blog_form(&$node, &$error) {
** database and quote it in the blog:
*/
if ($nid && $blog = node_load(array("nid" => $nid))) {
$node->body = "<i>". $blog->body ."</i> [". l($blog->name, "node/view/$nid") ."]";
if ($nid && $blog = node_load(array('nid' => $nid))) {
$node->body = '<i>'. $blog->body .'</i> ['. l($blog->name, "node/view/$nid") .']';
}
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM {item} i, {feed} f WHERE i.iid = %d AND i.fid = f.fid", $iid))) {
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {item} i, {feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
$node->title = $item->title;
$node->body = "<a href=\"$item->link\">$item->title</a> - <i>". check_output($item->description) ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
}
}
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("blog", $node));
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('blog', $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : filter_tips_short());
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, $error['body'] ? $error['body'] : filter_tips_short());
return $output;
}
function blog_page() {
switch (arg(1)) {
case "feed":
if (arg(2)) {
blog_feed_user(arg(2));
}
else {
blog_feed_last();
}
break;
default:
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
}
}
/**
* Implementation of hook_content().
*/
function blog_content($node, $main = 0) {
return node_prepare($node, $main);
}
/**
* Implementation of hook_view().
*/
function blog_view($node, $main = 0, $page = 0) {
if ($page) {
// Breadcrumb navigation
$breadcrumb[] = l(t("Home"), "");
$breadcrumb[] = l(t("blogs"), "blog");
$breadcrumb[] = l(t("%name's blog", array("%name" => $node->name)), "blog/$node->uid");
$breadcrumb[] = l(t('Home'), '');
$breadcrumb[] = l(t('blogs'), 'blog');
$breadcrumb[] = l(t("%name's blog", array('%name' => $node->name)), "blog/$node->uid");
// set the breadcrumb
drupal_set_breadcrumb($breadcrumb);
}
// prepare the node content
$node = blog_content($node, $main);
// print the node
return theme("node", $node, $main, $page);
return theme('node', $node, $main, $page);
}
/**
@ -220,9 +253,10 @@ function blog_link($type, $node = 0, $main) {
$links = array();
if ($type == 'system') {
menu('node/add/blog', t('blog entry'), user_access('maintain personal blog') ? 'node_page' : MENU_DENIED, 0);
menu('node/add/blog', t('blog entry'), user_access('maintain personal blog') ? MENU_FALLTHROUGH : MENU_DENIED, 0);
menu('blog/'. $user->uid, t('my blog'), user_access('maintain personal blog') ? 'blog_page' : MENU_DENIED, 1, MENU_SHOW, MENU_LOCKED);
menu('blog', t('blogs'), user_access('access content') ? 'blog_page' : MENU_DENIED, 0, MENU_HIDE);
menu('blog/feed', t('RSS feed'), user_access('access content') ? 'blog_feed' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
}
if ($type == 'page' && user_access('access content')) {
@ -241,17 +275,22 @@ function blog_link($type, $node = 0, $main) {
return $links;
}
function blog_block($op = "list", $delta = 0) {
/**
* Implementation of hook_block().
*
* Displays the most recent 10 blog titles.
*/
function blog_block($op = 'list', $delta = 0) {
global $user;
if ($op == "list") {
$block[0]["info"] = t("Blogs");
if ($op == 'list') {
$block[0]['info'] = t('Blogs');
return $block;
}
else {
if (user_access("access content")) {
$block["content"] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] .= "<div class=\"more-link\">". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."</div>";
$block["subject"] = t("Blogs");
if (user_access('access content')) {
$block['content'] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block['content'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>';
$block['subject'] = t('Blogs');
}
return $block;
}

View File

@ -4,7 +4,7 @@
/**
* Implementation of hook_help().
*/
function statistics_help($section = 'admin/help#statistics') {
function statistics_help($section) {
switch ($section) {
case 'admin/help#statistics':
return t("
@ -47,31 +47,20 @@ function statistics_help($section = 'admin/help#statistics') {
</ul>
<p>If '<em>administer statistics</em>' and '<em>access statistics</em>' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).</p>",
array('%modules' => url('admin/system/modules'), '%permissions' => url('admin/user/permission'), '%referer' => url('admin/logs/referrer'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/system/modules/statistics'), '%block' => url('admin/system/block')));
break;
case 'admin/system/modules#description':
return t('Logs access statistics for your site.');
break;
case 'admin/system/modules/statistics':
return t('Settings for the statistical information that Drupal will keep about the site. See <a href="%statistics">site statistics</a> for the actual information.', array('%statistics' => url('admin/logs/topnodes')));
break;
case 'admin/logs/topnodes':
return t('This page gives you an at-a-glance look at your most popular content.');
break;
case 'admin/logs/referrer':
return t('This page shows your site-wide referrer statistics. You can see "all referrers", "external referrers" or "internal referrers". Referrers are web pages, both local and on other sites, that point to your web site.');
break;
case 'admin/logs/referrer/internal':
return t('This page shows you only "internal referrers". These are links pointing to your web site from within your web site.');
break;
case 'admin/logs/referrer/external':
return t('This page shows you only "external referrers". These are links pointing to your web site from outside your web site.');
break;
case 'admin/logs/access':
case 'admin/logs/access/node':
case 'admin/logs/access/user':
case 'admin/logs/access/host':
case strstr($section, 'admin/logs/access'):
return t("This page shows you who is accessing your web site. You can see the hostnames and referrers. In particular, it is easy to inspect a user's navigation history/trail by clicking on <em>track user</em>.");
break;
}
}

View File

@ -4,7 +4,7 @@
/**
* Implementation of hook_help().
*/
function statistics_help($section = 'admin/help#statistics') {
function statistics_help($section) {
switch ($section) {
case 'admin/help#statistics':
return t("
@ -47,31 +47,20 @@ function statistics_help($section = 'admin/help#statistics') {
</ul>
<p>If '<em>administer statistics</em>' and '<em>access statistics</em>' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).</p>",
array('%modules' => url('admin/system/modules'), '%permissions' => url('admin/user/permission'), '%referer' => url('admin/logs/referrer'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/system/modules/statistics'), '%block' => url('admin/system/block')));
break;
case 'admin/system/modules#description':
return t('Logs access statistics for your site.');
break;
case 'admin/system/modules/statistics':
return t('Settings for the statistical information that Drupal will keep about the site. See <a href="%statistics">site statistics</a> for the actual information.', array('%statistics' => url('admin/logs/topnodes')));
break;
case 'admin/logs/topnodes':
return t('This page gives you an at-a-glance look at your most popular content.');
break;
case 'admin/logs/referrer':
return t('This page shows your site-wide referrer statistics. You can see "all referrers", "external referrers" or "internal referrers". Referrers are web pages, both local and on other sites, that point to your web site.');
break;
case 'admin/logs/referrer/internal':
return t('This page shows you only "internal referrers". These are links pointing to your web site from within your web site.');
break;
case 'admin/logs/referrer/external':
return t('This page shows you only "external referrers". These are links pointing to your web site from outside your web site.');
break;
case 'admin/logs/access':
case 'admin/logs/access/node':
case 'admin/logs/access/user':
case 'admin/logs/access/host':
case strstr($section, 'admin/logs/access'):
return t("This page shows you who is accessing your web site. You can see the hostnames and referrers. In particular, it is easy to inspect a user's navigation history/trail by clicking on <em>track user</em>.");
break;
}
}

View File

@ -2,81 +2,72 @@
// $Id$
/**
* Provide online user help
* Implementation of hook_help().
*/
function story_help($section = "admin/help#story") {
$output = "";
function story_help($section) {
switch ($section) {
case 'admin/system/modules#description':
$output = t("Enables users to submit stories, articles or similar content.");
break;
return t('Enables users to submit stories, articles or similar content.');
case 'admin/system/modules/story':
$output = t("Stories are like newspaper articles. They tend to follow a publishing flow of <strong>submit -&gt; moderate -&gt; post to the main page -&gt; comments</strong>. Below you may fix a minimum word count for stories and also write some submission or content guidelines for users wanting to post a story.");
break;
return t("Stories are like newspaper articles. They tend to follow a publishing flow of <strong>submit -&gt; moderate -&gt; post to the main page -&gt; comments</strong>. Below you may fix a minimum word count for stories and also write some submission or content guidelines for users wanting to post a story.");
case 'admin/help#story':
$output = t("
return t("
<p>The story module lets your users submit articles for consideration by the rest of the community, who can vote on them if moderation is enabled. Stories usually follow a publishing flow of <strong>submit -&gt; moderate -&gt; post to the main page -&gt; comments</strong>. Administrators are able to shortcut this flow as desired.</p>
In <a href=\"%story-config\">administer &raquo; configuration &raquo; modules &raquo; story</a> you can set up an introductory text for story authors, and a floor on the number of words which may be included in a story. This is designed to help discourage the submission of trivially short stories.</p>
<h3>User access permissions for stories</h3>
<p><strong>create stories:</strong> Allows a role to create stories. They cannot edit or delete stories, even if they are the authors. You must enable this permission to in order for a role to create a story.</p>
<p><strong>maintain personal stories:</strong> Allows a role to add/edit stories if they own the story. Use this permission if you want users to be able to edit and maintain their own stories.</p>
", array("%story-config" => url("admin/system/modules/story")));
break;
", array('%story-config' => url('admin/system/modules/story')));
case 'node/add/story':
$output = variable_get('story_help', '');
break;
return variable_get('story_help', '');
case 'node/add#story':
$output = t("A story is similar to a newspaper article. If stories are moderated, the post will be submitted to the attention of other users and be queued in the submission queue. Users and moderators vote on the posts they like or dislike, promoting or demoting them. When a post gets above a certain threshold it automatically gets promoted to the front page.");
break;
return t("A story is similar to a newspaper article. If stories are moderated, the post will be submitted to the attention of other users and be queued in the submission queue. Users and moderators vote on the posts they like or dislike, promoting or demoting them. When a post gets above a certain threshold it automatically gets promoted to the front page.");
}
return $output;
}
/**
* Declare administrative settings for a module.
* Implementation of hook_settings().
*/
function story_settings() {
$output .= form_textarea(t("Explanation or submission guidelines"), "story_help", variable_get("story_help", ""), 70, 5, t("This text will be displayed at the top of the story submission form. It is useful for helping or instructing your users."));
$output .= form_select(t("Minimum number of words"), "minimum_story_size", variable_get("minimum_story_size", 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t("The minimum number of words a story must be to be considered valid. This can be useful to rule out submissions that do not meet the site's standards, such as short test posts."));
$output .= form_textarea(t('Explanation or submission guidelines'), 'story_help', variable_get('story_help', ''), 70, 5, t('This text will be displayed at the top of the story submission form. It is useful for helping or instructing your users.'));
$output .= form_select(t('Minimum number of words'), 'minimum_story_size', variable_get('minimum_story_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t('The minimum number of words a story must be to be considered valid. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.'));
return $output;
}
/**
* Define the human-readable name of a node type.
* Implementation of hook_node_name().
*/
function story_node_name($node) {
return t("story");
return t('story');
}
/**
* Define user permissions.
* Implementation of hook_perm().
*/
function story_perm() {
return array('create stories', 'maintain personal stories');
}
/**
* Define access restrictions
* Implementation of hook_access().
*/
function story_access($op, $node) {
global $user;
if ($op == "view") {
if ($op == 'view') {
return $node->status;
}
if ($op == "create") {
if ($op == 'create') {
return user_access('create stories');
}
if ($op == "update") {
if ($op == 'update') {
return user_access('maintain personal stories') && ($user->uid == $node->uid);
}
if ($op == "delete") {
if ($op == 'delete') {
return user_access('maintain personal stories') && ($user->uid == $node->uid);
}
}
@ -88,7 +79,7 @@ function story_link($type, $node = 0, $main) {
$links = array();
if ($type == 'system') {
menu('node/add/story', t('story'), story_access('create', $node) ? 'node_page' : MENU_DENIED, 0);
menu('node/add/story', t('story'), story_access('create', $node) ? MENU_FALLTHROUGH : MENU_DENIED, 0);
}
if ($type == 'node' && $node->type == 'story') {
@ -102,37 +93,35 @@ function story_link($type, $node = 0, $main) {
}
/**
* Verify a node editing form.
* Implementation of hook_validate().
*
* Ensures the story is of adequate length.
*/
function story_validate(&$node) {
/*
** Validate the size of the story:
*/
if (isset($node->body) && count(explode(" ", $node->body)) < variable_get("minimum_story_size", 0)) {
$error["body"] = t("The body of your story is too short. You need at least %word_count words to submit your story.", array('%word_count' => variable_get("minimum_story_size", 0)));
if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_story_size', 0)) {
$error['body'] = t('The body of your story is too short. You need at least %word_count words to submit your story.', array('%word_count' => variable_get('minimum_story_size', 0)));
}
return $error;
}
/**
* Display a node editing form
* Implementation of hook_form().
*/
function story_form(&$node, &$error) {
$output = '';
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("story", $node));
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('story', $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, ($error["body"] ? theme('error', $error["body"]) : ''). filter_tips_short());
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, ($error['body'] ? theme('error', $error['body']) : ''). filter_tips_short());
return $output;
}
/**
* Prepare a node's body content for viewing
* Implementation of hook_content().
*/
function story_content($node, $main = 0) {
return node_prepare($node, $main);

View File

@ -2,81 +2,72 @@
// $Id$
/**
* Provide online user help
* Implementation of hook_help().
*/
function story_help($section = "admin/help#story") {
$output = "";
function story_help($section) {
switch ($section) {
case 'admin/system/modules#description':
$output = t("Enables users to submit stories, articles or similar content.");
break;
return t('Enables users to submit stories, articles or similar content.');
case 'admin/system/modules/story':
$output = t("Stories are like newspaper articles. They tend to follow a publishing flow of <strong>submit -&gt; moderate -&gt; post to the main page -&gt; comments</strong>. Below you may fix a minimum word count for stories and also write some submission or content guidelines for users wanting to post a story.");
break;
return t("Stories are like newspaper articles. They tend to follow a publishing flow of <strong>submit -&gt; moderate -&gt; post to the main page -&gt; comments</strong>. Below you may fix a minimum word count for stories and also write some submission or content guidelines for users wanting to post a story.");
case 'admin/help#story':
$output = t("
return t("
<p>The story module lets your users submit articles for consideration by the rest of the community, who can vote on them if moderation is enabled. Stories usually follow a publishing flow of <strong>submit -&gt; moderate -&gt; post to the main page -&gt; comments</strong>. Administrators are able to shortcut this flow as desired.</p>
In <a href=\"%story-config\">administer &raquo; configuration &raquo; modules &raquo; story</a> you can set up an introductory text for story authors, and a floor on the number of words which may be included in a story. This is designed to help discourage the submission of trivially short stories.</p>
<h3>User access permissions for stories</h3>
<p><strong>create stories:</strong> Allows a role to create stories. They cannot edit or delete stories, even if they are the authors. You must enable this permission to in order for a role to create a story.</p>
<p><strong>maintain personal stories:</strong> Allows a role to add/edit stories if they own the story. Use this permission if you want users to be able to edit and maintain their own stories.</p>
", array("%story-config" => url("admin/system/modules/story")));
break;
", array('%story-config' => url('admin/system/modules/story')));
case 'node/add/story':
$output = variable_get('story_help', '');
break;
return variable_get('story_help', '');
case 'node/add#story':
$output = t("A story is similar to a newspaper article. If stories are moderated, the post will be submitted to the attention of other users and be queued in the submission queue. Users and moderators vote on the posts they like or dislike, promoting or demoting them. When a post gets above a certain threshold it automatically gets promoted to the front page.");
break;
return t("A story is similar to a newspaper article. If stories are moderated, the post will be submitted to the attention of other users and be queued in the submission queue. Users and moderators vote on the posts they like or dislike, promoting or demoting them. When a post gets above a certain threshold it automatically gets promoted to the front page.");
}
return $output;
}
/**
* Declare administrative settings for a module.
* Implementation of hook_settings().
*/
function story_settings() {
$output .= form_textarea(t("Explanation or submission guidelines"), "story_help", variable_get("story_help", ""), 70, 5, t("This text will be displayed at the top of the story submission form. It is useful for helping or instructing your users."));
$output .= form_select(t("Minimum number of words"), "minimum_story_size", variable_get("minimum_story_size", 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t("The minimum number of words a story must be to be considered valid. This can be useful to rule out submissions that do not meet the site's standards, such as short test posts."));
$output .= form_textarea(t('Explanation or submission guidelines'), 'story_help', variable_get('story_help', ''), 70, 5, t('This text will be displayed at the top of the story submission form. It is useful for helping or instructing your users.'));
$output .= form_select(t('Minimum number of words'), 'minimum_story_size', variable_get('minimum_story_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t('The minimum number of words a story must be to be considered valid. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.'));
return $output;
}
/**
* Define the human-readable name of a node type.
* Implementation of hook_node_name().
*/
function story_node_name($node) {
return t("story");
return t('story');
}
/**
* Define user permissions.
* Implementation of hook_perm().
*/
function story_perm() {
return array('create stories', 'maintain personal stories');
}
/**
* Define access restrictions
* Implementation of hook_access().
*/
function story_access($op, $node) {
global $user;
if ($op == "view") {
if ($op == 'view') {
return $node->status;
}
if ($op == "create") {
if ($op == 'create') {
return user_access('create stories');
}
if ($op == "update") {
if ($op == 'update') {
return user_access('maintain personal stories') && ($user->uid == $node->uid);
}
if ($op == "delete") {
if ($op == 'delete') {
return user_access('maintain personal stories') && ($user->uid == $node->uid);
}
}
@ -88,7 +79,7 @@ function story_link($type, $node = 0, $main) {
$links = array();
if ($type == 'system') {
menu('node/add/story', t('story'), story_access('create', $node) ? 'node_page' : MENU_DENIED, 0);
menu('node/add/story', t('story'), story_access('create', $node) ? MENU_FALLTHROUGH : MENU_DENIED, 0);
}
if ($type == 'node' && $node->type == 'story') {
@ -102,37 +93,35 @@ function story_link($type, $node = 0, $main) {
}
/**
* Verify a node editing form.
* Implementation of hook_validate().
*
* Ensures the story is of adequate length.
*/
function story_validate(&$node) {
/*
** Validate the size of the story:
*/
if (isset($node->body) && count(explode(" ", $node->body)) < variable_get("minimum_story_size", 0)) {
$error["body"] = t("The body of your story is too short. You need at least %word_count words to submit your story.", array('%word_count' => variable_get("minimum_story_size", 0)));
if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_story_size', 0)) {
$error['body'] = t('The body of your story is too short. You need at least %word_count words to submit your story.', array('%word_count' => variable_get('minimum_story_size', 0)));
}
return $error;
}
/**
* Display a node editing form
* Implementation of hook_form().
*/
function story_form(&$node, &$error) {
$output = '';
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("story", $node));
if (function_exists('taxonomy_node_form')) {
$output .= implode('', taxonomy_node_form('story', $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, ($error["body"] ? theme('error', $error["body"]) : ''). filter_tips_short());
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, ($error['body'] ? theme('error', $error['body']) : ''). filter_tips_short());
return $output;
}
/**
* Prepare a node's body content for viewing
* Implementation of hook_content().
*/
function story_content($node, $main = 0) {
return node_prepare($node, $main);