From 8a2d5bede9a25af940fc5be248e81911fe056328 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 16 Aug 2003 05:49:45 +0000 Subject: - Rewrote handling of forum icons and added default icons made by Steven Wittens. - Renamed some column titles in the forum module as per Moshe's suggestion. - Introduced a 'more-link' class to position the 'more' links. Removed hard-coded markup from the modules. - Fixed bug in import module: the theme functions called a non-existing function. --- modules/aggregator.module | 16 ++--- modules/aggregator/aggregator.module | 16 ++--- modules/blog.module | 2 +- modules/blog/blog.module | 2 +- modules/cloud.module | 2 +- modules/forum.module | 109 ++++++++--------------------------- modules/forum/forum.module | 109 ++++++++--------------------------- modules/import.module | 16 ++--- 8 files changed, 67 insertions(+), 205 deletions(-) (limited to 'modules') diff --git a/modules/aggregator.module b/modules/aggregator.module index 1ed5dd648..4ae74fd54 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -108,7 +108,7 @@ function import_update() { } } -function import_format_item($item, $feed = 0) { +function import_theme_format_item($item, $feed = 0) { global $user; if ($user->uid && module_exist("blog") && user_access("maintain personal blog")) { @@ -132,7 +132,7 @@ function import_bundle_block($attributes) { $items = array(); while ($item = db_fetch_object($result)) { - $items[] = theme("import_theme_format_item",$item); + $items[] = theme("import_theme_format_item", $item); } $output = "
"; @@ -177,13 +177,13 @@ function import_block($op, $delta) { case "feed": $feed = db_fetch_object(db_query("SELECT * FROM {feed} WHERE fid = %d", $id)); $block["subject"] = $feed->title; - $block["content"] .= import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; + $block["content"] .= import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; break; case "bundle": $bundle = db_fetch_object(db_query("SELECT * FROM {bundle} WHERE bid = %d", $id)); $block["subject"] = $bundle->title; - $block["content"] .= import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; + $block["content"] .= import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; break; } @@ -198,9 +198,7 @@ function import_get_bundles($attributes = 0) { $result = db_query("SELECT * FROM {bundle} ORDER BY title"); while ($bundle = db_fetch_object($result)) { $block["bundle:$bundle->bid"]["subject"] = $bundle->title; - $block["bundle:$bundle->bid"]["content"] = import_bundle_block($bundle->attributes) ."
". - l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) - ."
"; + $block["bundle:$bundle->bid"]["content"] = import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; $block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle"; } @@ -214,9 +212,7 @@ function import_get_feeds($attributes = 0) { $result = db_query("SELECT * FROM {feed} ORDER BY fid"); while ($feed = db_fetch_object($result)) { $block["feed:$feed->fid"]["subject"] = $feed->title; - $block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."
". - l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) - ."
"; + $block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; $block["feed:$feed->fid"]["info"] = "$feed->title feed"; } diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 1ed5dd648..4ae74fd54 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -108,7 +108,7 @@ function import_update() { } } -function import_format_item($item, $feed = 0) { +function import_theme_format_item($item, $feed = 0) { global $user; if ($user->uid && module_exist("blog") && user_access("maintain personal blog")) { @@ -132,7 +132,7 @@ function import_bundle_block($attributes) { $items = array(); while ($item = db_fetch_object($result)) { - $items[] = theme("import_theme_format_item",$item); + $items[] = theme("import_theme_format_item", $item); } $output = "
"; @@ -177,13 +177,13 @@ function import_block($op, $delta) { case "feed": $feed = db_fetch_object(db_query("SELECT * FROM {feed} WHERE fid = %d", $id)); $block["subject"] = $feed->title; - $block["content"] .= import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; + $block["content"] .= import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; break; case "bundle": $bundle = db_fetch_object(db_query("SELECT * FROM {bundle} WHERE bid = %d", $id)); $block["subject"] = $bundle->title; - $block["content"] .= import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; + $block["content"] .= import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; break; } @@ -198,9 +198,7 @@ function import_get_bundles($attributes = 0) { $result = db_query("SELECT * FROM {bundle} ORDER BY title"); while ($bundle = db_fetch_object($result)) { $block["bundle:$bundle->bid"]["subject"] = $bundle->title; - $block["bundle:$bundle->bid"]["content"] = import_bundle_block($bundle->attributes) ."
". - l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) - ."
"; + $block["bundle:$bundle->bid"]["content"] = import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; $block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle"; } @@ -214,9 +212,7 @@ function import_get_feeds($attributes = 0) { $result = db_query("SELECT * FROM {feed} ORDER BY fid"); while ($feed = db_fetch_object($result)) { $block["feed:$feed->fid"]["subject"] = $feed->title; - $block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."
". - l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) - ."
"; + $block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; $block["feed:$feed->fid"]["info"] = "$feed->title feed"; } diff --git a/modules/blog.module b/modules/blog.module index 1f3d1ed20..773e42283 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -266,7 +266,7 @@ function blog_block($op = "list", $delta = 0) { 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"] .= "
". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."
"; + $block["content"] .= "
". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."
"; $block["subject"] = t("Blogs"); } return $block; diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 1f3d1ed20..773e42283 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -266,7 +266,7 @@ function blog_block($op = "list", $delta = 0) { 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"] .= "
". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."
"; + $block["content"] .= "
". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."
"; $block["subject"] = t("Blogs"); } return $block; diff --git a/modules/cloud.module b/modules/cloud.module index 6cd0b8290..64a8781b6 100644 --- a/modules/cloud.module +++ b/modules/cloud.module @@ -212,7 +212,7 @@ function cloud_block($op = "list", $delta = 0) { } else { $block["subject"] = t("Site cloud"); - $block["content"] = cloud_list(20) ."
". l(t("more"), "cloud", array("title" => t("Monitor other sites in the cloud."))) ."
"; + $block["content"] = cloud_list(20) ."
". l(t("more"), "cloud", array("title" => t("Monitor other sites in the cloud."))) ."
"; return $block; } } diff --git a/modules/forum.module b/modules/forum.module index 3b855574b..e1ce357af 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -41,8 +41,7 @@ function forum_settings() { if ($voc) { $output .= form_textarea(t("Explanation or submission guidelines"), "forum_help", variable_get("forum_help", ""), 70, 5, t("This text will be displayed at the top of the forum submission form. Useful for helping or instructing your users.")); $output .= form_select(t("Forum vocabulary"), "forum_nav_vocabulary", variable_get("forum_nav_vocabulary", ""), $vocs, t("The taxonomy vocabulary that will be used as the navigation tree.")); - $output .= form_textfield(t("Topic icons path"), "forum_topic_icon_path", variable_get("forum_topic_icon_path", ""), 30, 255, t("The path to the topic icons. Leave blank to disable icons.")); - $output .= form_textfield(t("Folder icons path"), "forum_folder_icon_path", variable_get("forum_folder_icon_path", ""), 30, 255,t( "The path to the default, hot, new, hot & new, and closed folder icons. Leave blank to disable icons.")); + $output .= form_textfield(t("Forum icon path"), "forum_icon_path", variable_get("forum_icon_path", ""), 30, 255, t("The path to the forum icons. Leave blank to disable icons. Don't add a trailing slash. Default icons are available in the 'misc' directory.")); $number = array(5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 50 => 50, 60 => 60, 80 => 80, 100 => 100, 10000=>10000); $output .= form_select(t("Hot topic threshold"), "forum_hot_topic", variable_get("forum_hot_topic", 15), $number, t("The number of posts a topic must have to be considered hot.")); $number = array(10 => 10, 25 => 25, 50 => 50, 75 => 75, 100 => 100); @@ -88,7 +87,7 @@ function forum_block($op = "list", $delta = 0) { $content .= node_title_list(db_query_range("SELECT n.nid, n.title, u.uid, u.name FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid LEFT JOIN {users} u ON n.uid = u.uid WHERE n.type = 'forum' ORDER BY n.nid DESC", 0, variable_get("forum_block_num", "5")), t("New forum topics:")); if ($content) { - $content .= "
". l(t("more"), "forum", array("title" => t("Read the latest forum topics."))) ."
"; + $content .= "
". l(t("more"), "forum", array("title" => t("Read the latest forum topics."))) ."
"; } $blocks["subject"] = t("Forum topics"); @@ -198,63 +197,17 @@ function forum_form(&$node, &$help, &$error) { $output .= form_checkbox(t("Leave shadow copy"), "shadow", 1, $node->shadow, t("If you move this topic, you can leave a link in the old forum to the new forum.")); } - if ($icon_path = variable_get("forum_topic_icon_path", "")) { - if ($node->icon) { - // we are editing post - if ($dir = @opendir($icon_path)) { - $icon_num = 0; - while($icon = readdir($dir)) { - if ($icon == '.' || $icon == '..') {continue;} - if ($node->icon == $icon) {$checked = "checked";} else {$checked = "";} - $radio .= "\"\" \n"; - $icon_num++; - } - closedir($dir); - } - } - else { - if ($dir = @opendir($icon_path)) { - $icon_num = 0; - while($icon = readdir($dir)) { - if ($icon == '.' || $icon == '..') {continue;} - if ($node->icon_num == $icon_num) {$checked = "checked";} else {$checked = "";} - $radio .= "\"\" \n"; - $icon_num++; - } - closedir($dir); - } - } - $output .= form_item(t("Topic icon"), $radio); - } $output .= form_textarea(t("Body"), "body", $node->body, 60, 10); return $output; } function forum_insert($node) { - $node->icon = _forum_decode_icon($node); - db_query("INSERT INTO {forum} (nid, icon, shadow, tid) VALUES (%d, '%s', %d, %d)", $node->nid, $node->icon, $node->shadow, $node->tid[0]); + db_query("INSERT INTO {forum} (nid, shadow, tid) VALUES (%d, %d, %d)", $node->nid, $node->shadow, $node->tid[0]); } function forum_update($node) { - $node->icon = _forum_decode_icon($node); - db_query("UPDATE {forum} SET icon = '%s', shadow = %d, tid = %d WHERE nid = %d", $node->icon, $node->shadow, $node->tid[0], $node->nid); -} - -function _forum_decode_icon($node) { - // to prevent malicious users - if ($icon_path = variable_get("forum_topic_icon_path", "")) { - if ($dir = @opendir($icon_path)) { - $icon_num = 0; - while($icon = readdir($dir)) { - if ($icon == '.' || $icon == '..') {continue;} - if ($icon_num == $node->icon_num) {$myicon = $icon;} - $icon_num++; - } - closedir($dir); - } - } - return $myicon; + db_query("UPDATE {forum} SET shadow = %d, tid = %d WHERE nid = %d", $node->shadow, $node->tid[0], $node->nid); } function forum_delete(&$node) { @@ -374,7 +327,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $sql_sortby = _forum_get_topic_order($sortby); // show topics with the correct tid, or in the forum but with shadow = 1 - $sql = "SELECT n.nid, n.title, u.name AS name, u.uid AS uid, n.created AS timestamp, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments, f.icon, n.comment AS comment_mode, f.tid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid LEFT JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid INNER JOIN {forum} f ON n.nid = f.nid WHERE n.nid = r.nid AND ((r.tid = '".check_query($tid)."' AND f.shadow = 1) OR f.tid = '".check_query($tid)."') AND n.status = 1 AND n.type = 'forum' GROUP BY n.nid, n.title, u.name, u.uid, n.created, n.comment, f.tid, f.icon ORDER BY $sql_sortby"; + $sql = "SELECT n.nid, n.title, u.name AS name, u.uid AS uid, n.created AS timestamp, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments, n.comment AS comment_mode, f.tid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid LEFT JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid INNER JOIN {forum} f ON n.nid = f.nid WHERE n.nid = r.nid AND ((r.tid = '".check_query($tid)."' AND f.shadow = 1) OR f.tid = '".check_query($tid)."') AND n.status = 1 AND n.type = 'forum' GROUP BY n.nid, n.title, u.name, u.uid, n.created, n.comment, f.tid ORDER BY $sql_sortby"; $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {term_node} r ON n.nid = r.nid WHERE n.nid = r.nid AND ( (r.tid = '".check_query($tid)."' AND f.shadow = 1) OR f.tid = '".check_query($tid)."') AND n.status = 1 AND n.type = 'forum'"; @@ -533,7 +486,7 @@ function forum_theme_list($forums, $parents, $tid) { if ($forums) { - $header = array(array("data" => t("Forum"), "colspan" => "2"), t("Topics"), t("Posts"), t("Last post")); + $header = array(t("Forum"), t("Topics"), t("Posts"), t("Last post")); foreach ($forums as $forum) { if ($user->uid) { @@ -561,13 +514,11 @@ function forum_theme_list($forums, $parents, $tid) { } $description .="
\n"; - //if ($icon = _forum_get_folder_icon($new_topics)) { $rows[] = array( - array("data" => $icon, "class" => "icon"), array("data" => $description, "class" => "description"), array("data" => $forum->num_topics . ($new_topics ? "
(".t("%a new", array("%a" => $new_topics)).")" : ""), "class" => "topics"), array("data" => $forum->num_posts, "class" => "posts"), - array("data" => _forum_format($forum->last_post), "class" => "last-post") + array("data" => _forum_format($forum->last_post), "class" => "last-reply") ); } @@ -610,35 +561,33 @@ function forum_theme_topic_list($tid, $topics, $sortby, $forum_per_page, $offset if ($topics) { - $header = array(array("data" => t("Topic"), "colspan" => "3"), t("Replies"), t("Posted"), t("Last post")); + $header = array(array("data" => t("Topic"), "colspan" => "2"), t("Replies"), t("Created"), t("Last reply")); foreach ($topics as $topic) { // folder is new if topic is new or there are new comments since last visit if ($topic->tid != $tid) { $rows[] = array( - array("data" => _forum_get_folder_icon($topic->new, $topic->num_comments, $topic->comment_mode), "class" => "icon"), - array("data" =>_forum_get_icon($topic), "class" => "icon"), + array("data" => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), "class" => "icon"), array("data" => $topic->title, "class" => "title"), - array("data" => l(t("This topic has been moved"), "forum/$topic->tid"), "colspan" => 3) + array("data" => l(t("This topic has been moved"), "forum/$topic->tid"), "colspan" => "3") ); } else { $rows[] = array( - array("data" => _forum_get_folder_icon($topic->new, $topic->num_comments, $topic->comment_mode), "class" => "icon"), - array("data" => _forum_get_icon($topic), "class" => "icon"), + array("data" => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), "class" => "icon"), array("data" => l($topic->title, "node/view/$topic->nid"), "class" => "topic"), array("data" => $topic->num_comments . ($topic->new_replies ? "
(".t("%a new", array("%a" => $topic->new_replies)).")" : ""), "class" => "replies"), - array("data" => _forum_format($topic), "class" => "posted"), - array("data" => _forum_format($topic->last_reply), "class" => "last-post") + array("data" => _forum_format($topic), "class" => "created"), + array("data" => _forum_format($topic->last_reply), "class" => "last-reply") ); } } - $rows[] = array(array("data" => t("%a topics, %b topics per page, page %c of %d", array("%a" => $pager_total[0], "%b" => $forum_per_page, "%c" => $offset, "%d" => ceil($pager_total[0]/$forum_per_page))), "colspan" => "6", "class" => "statistics")); - $rows[] = array(array("data" => theme("forum_theme_topic_browser", $sortby, $forum_per_page, $offset), "colspan" => "6", "class" => "settings")); + $rows[] = array(array("data" => t("%a topics, %b topics per page, page %c of %d", array("%a" => $pager_total[0], "%b" => $forum_per_page, "%c" => $offset, "%d" => ceil($pager_total[0]/$forum_per_page))), "colspan" => "5", "class" => "statistics")); + $rows[] = array(array("data" => theme("forum_theme_topic_browser", $sortby, $forum_per_page, $offset), "colspan" => "5", "class" => "settings")); if ($pager = pager_display(NULL, $forum_per_page, 0, "default")) { - $rows[] = array(array("data" => $pager, "colspan" => "6", "class" => "pager")); + $rows[] = array(array("data" => $pager, "colspan" => "5", "class" => "pager")); } } @@ -647,29 +596,17 @@ function forum_theme_topic_list($tid, $topics, $sortby, $forum_per_page, $offset $output = l(t("create new forum topic"), "node/add/forum/$tid") ."

"; } - $output .= table($header, $rows); + $output .= table($header, $rows); return $output; } +function _forum_icon($new_posts, $num_posts = 0, $comment_mode = 0) { -function _forum_get_icon($node) { - if (variable_get("forum_topic_icon_path", "") && $node->icon) { - return "icon\" />"; - } - else { - return " "; - } -} - -function _forum_get_folder_icon($new_posts, $num_posts = 0, $comment_mode = 0) { - // "folder" icon because it's generally rendered as a folder - - - $base_path = variable_get("forum_folder_icon_path", ""); + $base_path = variable_get("forum_icon_path", ""); if ($base_path) { if ($num_posts > variable_get("forum_hot_topic", 15)) { - $icon = $new_posts ? "hot_new" : "hot"; + $icon = $new_posts ? "hot-new" : "hot"; } else { $icon = $new_posts ? "new" : "default"; @@ -680,7 +617,7 @@ function _forum_get_folder_icon($new_posts, $num_posts = 0, $comment_mode = 0) { } // default - $file = $base_path."/".$icon.".gif"; + $file = $base_path."/forum-$icon.gif"; return "\"\""; } @@ -728,8 +665,8 @@ function forum_help($section = "admin/forum/help") { $output .= strtr("

The forum module uses taxonomy to organize itself. To create a forum you first have to create a %taxonomy. When doing this, choose a sensible name for it (such as \"fora\") and make sure under \"Types\" that \"forum\" is selected. Once you have done this, %taxo-terms to it. Each term will become a forum. If you fill in the description field, users will be given additonal information about the forum on the main forum page. For example: \"troubleshooting\" - \"Please ask your questions here.\"

", array("%taxonomy" => l(t("taxonomy vocabulary"), "admin/taxonomy/add/vocabulary"), "%taxo-terms" => l(t("add some terms"), "admin/taxonomy" ) )); $output .= strtr("

When you are happy with your vocabulary, go to ". l("site configuration » modules » forum","admin/system/modules/forum") ." and set Forum vocabulary to the one you have just created. There will now be fora active on the site. For users to access them they must have the \"access content\" %permission and to create a topic they must have the \"create forum topics\" %permission. These permissions can be set in the %permission pages.

", array("%forums" => l(t("site configutation » modules » forum"), "admin/system/modules/forum"), "%permission" => l(t("permission"), "admin/user/permission") )); $output .= "

Icons

"; - $output .= strtr("

To disable icons, set the icon path as blank in %forums-icon.

",array("%forums-icon" => l(t("site configuration » modules » forums"), "admin/system/module/forum") )); - $output .= "

All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is customary to use 15x15 or 16x16.

"; + $output .= strtr("

To disable icons, set the icon path as blank in %forums-icon.

", array("%forums-icon" => l(t("site configuration » modules » forums"), "admin/system/module/forum") )); + $output .= "

All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16.

"; break; case 'admin/system/modules': $output = "Enable threaded discussions about general topics."; diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 3b855574b..e1ce357af 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -41,8 +41,7 @@ function forum_settings() { if ($voc) { $output .= form_textarea(t("Explanation or submission guidelines"), "forum_help", variable_get("forum_help", ""), 70, 5, t("This text will be displayed at the top of the forum submission form. Useful for helping or instructing your users.")); $output .= form_select(t("Forum vocabulary"), "forum_nav_vocabulary", variable_get("forum_nav_vocabulary", ""), $vocs, t("The taxonomy vocabulary that will be used as the navigation tree.")); - $output .= form_textfield(t("Topic icons path"), "forum_topic_icon_path", variable_get("forum_topic_icon_path", ""), 30, 255, t("The path to the topic icons. Leave blank to disable icons.")); - $output .= form_textfield(t("Folder icons path"), "forum_folder_icon_path", variable_get("forum_folder_icon_path", ""), 30, 255,t( "The path to the default, hot, new, hot & new, and closed folder icons. Leave blank to disable icons.")); + $output .= form_textfield(t("Forum icon path"), "forum_icon_path", variable_get("forum_icon_path", ""), 30, 255, t("The path to the forum icons. Leave blank to disable icons. Don't add a trailing slash. Default icons are available in the 'misc' directory.")); $number = array(5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 50 => 50, 60 => 60, 80 => 80, 100 => 100, 10000=>10000); $output .= form_select(t("Hot topic threshold"), "forum_hot_topic", variable_get("forum_hot_topic", 15), $number, t("The number of posts a topic must have to be considered hot.")); $number = array(10 => 10, 25 => 25, 50 => 50, 75 => 75, 100 => 100); @@ -88,7 +87,7 @@ function forum_block($op = "list", $delta = 0) { $content .= node_title_list(db_query_range("SELECT n.nid, n.title, u.uid, u.name FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid LEFT JOIN {users} u ON n.uid = u.uid WHERE n.type = 'forum' ORDER BY n.nid DESC", 0, variable_get("forum_block_num", "5")), t("New forum topics:")); if ($content) { - $content .= "
". l(t("more"), "forum", array("title" => t("Read the latest forum topics."))) ."
"; + $content .= "
". l(t("more"), "forum", array("title" => t("Read the latest forum topics."))) ."
"; } $blocks["subject"] = t("Forum topics"); @@ -198,63 +197,17 @@ function forum_form(&$node, &$help, &$error) { $output .= form_checkbox(t("Leave shadow copy"), "shadow", 1, $node->shadow, t("If you move this topic, you can leave a link in the old forum to the new forum.")); } - if ($icon_path = variable_get("forum_topic_icon_path", "")) { - if ($node->icon) { - // we are editing post - if ($dir = @opendir($icon_path)) { - $icon_num = 0; - while($icon = readdir($dir)) { - if ($icon == '.' || $icon == '..') {continue;} - if ($node->icon == $icon) {$checked = "checked";} else {$checked = "";} - $radio .= "\"\" \n"; - $icon_num++; - } - closedir($dir); - } - } - else { - if ($dir = @opendir($icon_path)) { - $icon_num = 0; - while($icon = readdir($dir)) { - if ($icon == '.' || $icon == '..') {continue;} - if ($node->icon_num == $icon_num) {$checked = "checked";} else {$checked = "";} - $radio .= "\"\" \n"; - $icon_num++; - } - closedir($dir); - } - } - $output .= form_item(t("Topic icon"), $radio); - } $output .= form_textarea(t("Body"), "body", $node->body, 60, 10); return $output; } function forum_insert($node) { - $node->icon = _forum_decode_icon($node); - db_query("INSERT INTO {forum} (nid, icon, shadow, tid) VALUES (%d, '%s', %d, %d)", $node->nid, $node->icon, $node->shadow, $node->tid[0]); + db_query("INSERT INTO {forum} (nid, shadow, tid) VALUES (%d, %d, %d)", $node->nid, $node->shadow, $node->tid[0]); } function forum_update($node) { - $node->icon = _forum_decode_icon($node); - db_query("UPDATE {forum} SET icon = '%s', shadow = %d, tid = %d WHERE nid = %d", $node->icon, $node->shadow, $node->tid[0], $node->nid); -} - -function _forum_decode_icon($node) { - // to prevent malicious users - if ($icon_path = variable_get("forum_topic_icon_path", "")) { - if ($dir = @opendir($icon_path)) { - $icon_num = 0; - while($icon = readdir($dir)) { - if ($icon == '.' || $icon == '..') {continue;} - if ($icon_num == $node->icon_num) {$myicon = $icon;} - $icon_num++; - } - closedir($dir); - } - } - return $myicon; + db_query("UPDATE {forum} SET shadow = %d, tid = %d WHERE nid = %d", $node->shadow, $node->tid[0], $node->nid); } function forum_delete(&$node) { @@ -374,7 +327,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $sql_sortby = _forum_get_topic_order($sortby); // show topics with the correct tid, or in the forum but with shadow = 1 - $sql = "SELECT n.nid, n.title, u.name AS name, u.uid AS uid, n.created AS timestamp, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments, f.icon, n.comment AS comment_mode, f.tid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid LEFT JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid INNER JOIN {forum} f ON n.nid = f.nid WHERE n.nid = r.nid AND ((r.tid = '".check_query($tid)."' AND f.shadow = 1) OR f.tid = '".check_query($tid)."') AND n.status = 1 AND n.type = 'forum' GROUP BY n.nid, n.title, u.name, u.uid, n.created, n.comment, f.tid, f.icon ORDER BY $sql_sortby"; + $sql = "SELECT n.nid, n.title, u.name AS name, u.uid AS uid, n.created AS timestamp, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments, n.comment AS comment_mode, f.tid FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid LEFT JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid INNER JOIN {forum} f ON n.nid = f.nid WHERE n.nid = r.nid AND ((r.tid = '".check_query($tid)."' AND f.shadow = 1) OR f.tid = '".check_query($tid)."') AND n.status = 1 AND n.type = 'forum' GROUP BY n.nid, n.title, u.name, u.uid, n.created, n.comment, f.tid ORDER BY $sql_sortby"; $sql_count = "SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {forum} f ON n.nid = f.nid INNER JOIN {term_node} r ON n.nid = r.nid WHERE n.nid = r.nid AND ( (r.tid = '".check_query($tid)."' AND f.shadow = 1) OR f.tid = '".check_query($tid)."') AND n.status = 1 AND n.type = 'forum'"; @@ -533,7 +486,7 @@ function forum_theme_list($forums, $parents, $tid) { if ($forums) { - $header = array(array("data" => t("Forum"), "colspan" => "2"), t("Topics"), t("Posts"), t("Last post")); + $header = array(t("Forum"), t("Topics"), t("Posts"), t("Last post")); foreach ($forums as $forum) { if ($user->uid) { @@ -561,13 +514,11 @@ function forum_theme_list($forums, $parents, $tid) { } $description .="
\n"; - //if ($icon = _forum_get_folder_icon($new_topics)) { $rows[] = array( - array("data" => $icon, "class" => "icon"), array("data" => $description, "class" => "description"), array("data" => $forum->num_topics . ($new_topics ? "
(".t("%a new", array("%a" => $new_topics)).")" : ""), "class" => "topics"), array("data" => $forum->num_posts, "class" => "posts"), - array("data" => _forum_format($forum->last_post), "class" => "last-post") + array("data" => _forum_format($forum->last_post), "class" => "last-reply") ); } @@ -610,35 +561,33 @@ function forum_theme_topic_list($tid, $topics, $sortby, $forum_per_page, $offset if ($topics) { - $header = array(array("data" => t("Topic"), "colspan" => "3"), t("Replies"), t("Posted"), t("Last post")); + $header = array(array("data" => t("Topic"), "colspan" => "2"), t("Replies"), t("Created"), t("Last reply")); foreach ($topics as $topic) { // folder is new if topic is new or there are new comments since last visit if ($topic->tid != $tid) { $rows[] = array( - array("data" => _forum_get_folder_icon($topic->new, $topic->num_comments, $topic->comment_mode), "class" => "icon"), - array("data" =>_forum_get_icon($topic), "class" => "icon"), + array("data" => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), "class" => "icon"), array("data" => $topic->title, "class" => "title"), - array("data" => l(t("This topic has been moved"), "forum/$topic->tid"), "colspan" => 3) + array("data" => l(t("This topic has been moved"), "forum/$topic->tid"), "colspan" => "3") ); } else { $rows[] = array( - array("data" => _forum_get_folder_icon($topic->new, $topic->num_comments, $topic->comment_mode), "class" => "icon"), - array("data" => _forum_get_icon($topic), "class" => "icon"), + array("data" => _forum_icon($topic->new, $topic->num_comments, $topic->comment_mode), "class" => "icon"), array("data" => l($topic->title, "node/view/$topic->nid"), "class" => "topic"), array("data" => $topic->num_comments . ($topic->new_replies ? "
(".t("%a new", array("%a" => $topic->new_replies)).")" : ""), "class" => "replies"), - array("data" => _forum_format($topic), "class" => "posted"), - array("data" => _forum_format($topic->last_reply), "class" => "last-post") + array("data" => _forum_format($topic), "class" => "created"), + array("data" => _forum_format($topic->last_reply), "class" => "last-reply") ); } } - $rows[] = array(array("data" => t("%a topics, %b topics per page, page %c of %d", array("%a" => $pager_total[0], "%b" => $forum_per_page, "%c" => $offset, "%d" => ceil($pager_total[0]/$forum_per_page))), "colspan" => "6", "class" => "statistics")); - $rows[] = array(array("data" => theme("forum_theme_topic_browser", $sortby, $forum_per_page, $offset), "colspan" => "6", "class" => "settings")); + $rows[] = array(array("data" => t("%a topics, %b topics per page, page %c of %d", array("%a" => $pager_total[0], "%b" => $forum_per_page, "%c" => $offset, "%d" => ceil($pager_total[0]/$forum_per_page))), "colspan" => "5", "class" => "statistics")); + $rows[] = array(array("data" => theme("forum_theme_topic_browser", $sortby, $forum_per_page, $offset), "colspan" => "5", "class" => "settings")); if ($pager = pager_display(NULL, $forum_per_page, 0, "default")) { - $rows[] = array(array("data" => $pager, "colspan" => "6", "class" => "pager")); + $rows[] = array(array("data" => $pager, "colspan" => "5", "class" => "pager")); } } @@ -647,29 +596,17 @@ function forum_theme_topic_list($tid, $topics, $sortby, $forum_per_page, $offset $output = l(t("create new forum topic"), "node/add/forum/$tid") ."

"; } - $output .= table($header, $rows); + $output .= table($header, $rows); return $output; } +function _forum_icon($new_posts, $num_posts = 0, $comment_mode = 0) { -function _forum_get_icon($node) { - if (variable_get("forum_topic_icon_path", "") && $node->icon) { - return "icon\" />"; - } - else { - return " "; - } -} - -function _forum_get_folder_icon($new_posts, $num_posts = 0, $comment_mode = 0) { - // "folder" icon because it's generally rendered as a folder - - - $base_path = variable_get("forum_folder_icon_path", ""); + $base_path = variable_get("forum_icon_path", ""); if ($base_path) { if ($num_posts > variable_get("forum_hot_topic", 15)) { - $icon = $new_posts ? "hot_new" : "hot"; + $icon = $new_posts ? "hot-new" : "hot"; } else { $icon = $new_posts ? "new" : "default"; @@ -680,7 +617,7 @@ function _forum_get_folder_icon($new_posts, $num_posts = 0, $comment_mode = 0) { } // default - $file = $base_path."/".$icon.".gif"; + $file = $base_path."/forum-$icon.gif"; return "\"\""; } @@ -728,8 +665,8 @@ function forum_help($section = "admin/forum/help") { $output .= strtr("

The forum module uses taxonomy to organize itself. To create a forum you first have to create a %taxonomy. When doing this, choose a sensible name for it (such as \"fora\") and make sure under \"Types\" that \"forum\" is selected. Once you have done this, %taxo-terms to it. Each term will become a forum. If you fill in the description field, users will be given additonal information about the forum on the main forum page. For example: \"troubleshooting\" - \"Please ask your questions here.\"

", array("%taxonomy" => l(t("taxonomy vocabulary"), "admin/taxonomy/add/vocabulary"), "%taxo-terms" => l(t("add some terms"), "admin/taxonomy" ) )); $output .= strtr("

When you are happy with your vocabulary, go to ". l("site configuration » modules » forum","admin/system/modules/forum") ." and set Forum vocabulary to the one you have just created. There will now be fora active on the site. For users to access them they must have the \"access content\" %permission and to create a topic they must have the \"create forum topics\" %permission. These permissions can be set in the %permission pages.

", array("%forums" => l(t("site configutation » modules » forum"), "admin/system/modules/forum"), "%permission" => l(t("permission"), "admin/user/permission") )); $output .= "

Icons

"; - $output .= strtr("

To disable icons, set the icon path as blank in %forums-icon.

",array("%forums-icon" => l(t("site configuration » modules » forums"), "admin/system/module/forum") )); - $output .= "

All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is customary to use 15x15 or 16x16.

"; + $output .= strtr("

To disable icons, set the icon path as blank in %forums-icon.

", array("%forums-icon" => l(t("site configuration » modules » forums"), "admin/system/module/forum") )); + $output .= "

All files in the icon directory are assumed to be images. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16.

"; break; case 'admin/system/modules': $output = "Enable threaded discussions about general topics."; diff --git a/modules/import.module b/modules/import.module index 1ed5dd648..4ae74fd54 100644 --- a/modules/import.module +++ b/modules/import.module @@ -108,7 +108,7 @@ function import_update() { } } -function import_format_item($item, $feed = 0) { +function import_theme_format_item($item, $feed = 0) { global $user; if ($user->uid && module_exist("blog") && user_access("maintain personal blog")) { @@ -132,7 +132,7 @@ function import_bundle_block($attributes) { $items = array(); while ($item = db_fetch_object($result)) { - $items[] = theme("import_theme_format_item",$item); + $items[] = theme("import_theme_format_item", $item); } $output = "
"; @@ -177,13 +177,13 @@ function import_block($op, $delta) { case "feed": $feed = db_fetch_object(db_query("SELECT * FROM {feed} WHERE fid = %d", $id)); $block["subject"] = $feed->title; - $block["content"] .= import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; + $block["content"] .= import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; break; case "bundle": $bundle = db_fetch_object(db_query("SELECT * FROM {bundle} WHERE bid = %d", $id)); $block["subject"] = $bundle->title; - $block["content"] .= import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; + $block["content"] .= import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; break; } @@ -198,9 +198,7 @@ function import_get_bundles($attributes = 0) { $result = db_query("SELECT * FROM {bundle} ORDER BY title"); while ($bundle = db_fetch_object($result)) { $block["bundle:$bundle->bid"]["subject"] = $bundle->title; - $block["bundle:$bundle->bid"]["content"] = import_bundle_block($bundle->attributes) ."
". - l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) - ."
"; + $block["bundle:$bundle->bid"]["content"] = import_bundle_block($bundle->attributes) ."
". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
"; $block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle"; } @@ -214,9 +212,7 @@ function import_get_feeds($attributes = 0) { $result = db_query("SELECT * FROM {feed} ORDER BY fid"); while ($feed = db_fetch_object($result)) { $block["feed:$feed->fid"]["subject"] = $feed->title; - $block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."
". - l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) - ."
"; + $block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."
". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
"; $block["feed:$feed->fid"]["info"] = "$feed->title feed"; } -- cgit v1.2.3