Commit 91f5bce3 authored by The Great Git Migration's avatar The Great Git Migration
Browse files

This commit was manufactured as part of Drupal's Great Git Migration to

create tag 'DRUPAL-4-3-0'.

Sprout from master 2003-10-30 19:16:44 UTC Dries Buytaert <dries@buytaert.net> ''
Cherrypick from DRUPAL-4-3 2003-11-01 22:23:27 UTC Kjartan Mannes <kjartan@2.no-reply.drupal.org> '- Updating release info.':
    CHANGELOG
    database/database.mssql
    database/database.mysql
    database/database.pgsql
    modules/poll.module
    modules/user.module
Delete:
    modules/aggregator.module
    modules/aggregator/aggregator.module
    modules/archive/archive.module
    modules/block/block.module
    modules/blog/blog.module
    modules/book/book.module
    modules/comment/comment.module
    modules/drupal/drupal.module
    modules/forum/forum.module
    modules/help/help.module
    modules/locale/locale.module
    modules/node/node.module
    modules/page/page.module
    modules/path/path.module
    modules/ping/ping.module
    modules/poll/poll.module
    modules/profile/profile.module
    modules/search/search.module
    modules/statistics/statistics.module
    modules/story/story.module
    modules/system/system.module
    modules/taxonomy/taxonomy.module
    modules/throttle/throttle.module
    modules/tracker/tracker.module
    modules/user/user.module
    modules/watchdog/watchdog.module
parent 3c17d392
No related merge requests found
Showing with 5 additions and 8478 deletions
+5 -8478
Drupal x.x.x, xxxx-xx-xx (to be released)
Drupal 4.3.0, 2003-11-01
------------------------
- added support for configurable URLs.
......
......@@ -500,7 +500,7 @@ INSERT INTO system VALUES ('modules/story.module','story','module','',1);
INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1);
INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1);
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-10-22";');
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-10-27";');
INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";');
INSERT INTO users(uid,name,mail,rid) VALUES(0,'','','1');
......
......@@ -590,7 +590,7 @@ INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1);
INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1);
INSERT INTO users (uid, name, mail, rid) VALUES ('0', '', '', '1');
REPLACE variable SET name='update_start', value='s:10:"2003-10-22;"';
REPLACE variable SET name='update_start', value='s:10:"2003-10-27;"';
REPLACE variable SET name='theme_default', value='s:6:"marvin";';
REPLACE blocks SET module = 'user', delta = '0', status = '1';
......
......@@ -590,7 +590,7 @@ INSERT INTO system VALUES ('modules/story.module','story','module','',1);
INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1);
INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1);
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-10-22";');
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-10-27";');
INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";');
INSERT INTO users(uid,name,mail,rid) VALUES(0,'','', '1');
......
This diff is collapsed.
This diff is collapsed.
<?php
// $Id$
function archive_help($section) {
$output = "";
switch ($section) {
case 'admin/system/modules#description':
$output = t("Displays a calendar to navigate old content.");
break;
case 'admin/system/modules/archive':
$output = t("Choose the starting \"day of the week\" for the displayed calendar block.");
break;
}
return $output;
}
function archive_calendar($original = 0) {
global $user;
$edit = $_POST["edit"];
// Extract today's date:
$offset = time() + $user->timezone;
$start_of_today = mktime(0, 0, 0, date("n", $offset), date("d", $offset), date("Y", $offset)) + $user->timezone;
$end_of_today = mktime(23, 59, 59, date("n", $offset), date("d", $offset), date("Y", $offset)) + $user->timezone;
// Extract the requested date:
if ($edit["year"] && $edit["month"] && $edit["day"]) {
$year = $edit["year"];
$month = $edit["month"];
$day = $edit["day"];
$requested = mktime(0, 0, 0, $month, $day, $year) + $user->timezone;
}
else if (arg(0) == "archive" && arg(3)) {
$year = arg(1);
$month = arg(2);
$day = arg(3);
$requested = mktime(0, 0, 0, $month, $day, $year) + $user->timezone;
}
else {
$year = date("Y", time());
$month = date("n", time());
$day = date("d", time());
$requested = $end_of_today + $user->timezone;
}
$start_of_month = mktime(0, 0, 0, $month, 1, $year);
// Extract first day of the month:
$first = date("w", $start_of_month);
// Extract last day of the month:
$last = date("t", $start_of_month);
$end_of_month = mktime(23, 59, 59, $month, $last, $year);
$cache = cache_get("archive:calendar:$start_of_month");
if (!empty($cache)) {
return $cache->data;
}
// Calculate previous and next months dates and check for shorter months (28/30 days)
$prevmonth = mktime(23, 59, 59, $month - 1, 1, $year);
$prev = mktime(23, 59, 59, $month - 1, min(date("t", $prevmonth), $day), $year);
$nextmonth = mktime(23, 59, 59, $month + 1, 1, $year);
$next = mktime(23, 59, 59, $month + 1, min(date("t", $nextmonth), $day), $year);
$result = db_query("SELECT created FROM {node} WHERE status = 1 AND created > $start_of_month AND created < $end_of_month");
$days_with_posts = array();
while ($day_with_post = db_fetch_object($result)) {
$days_with_posts[] = date("j", $day_with_post->created + $user->timezone);
}
$days_with_posts = array_unique($days_with_posts);
// Generate calendar header:
$output .= "\n<!-- calendar -->\n";
$output .= "<div class=\"calendar\">";
$output .= "<table>\n";
$output .= " <tr><td colspan=\"7\" class=\"header-month\">". l("&laquo;", "archive/". date("Y/m/d", $prev)) ." ". date("F Y", $requested) ." ". ($nextmonth <= time() ? l("&raquo;", "archive/". date("Y/m/d", $next)) : "&nbsp;") ."</td></tr>\n";
// First day of week (0 => Sunday, 1 => Monday, ...)
$weekstart = variable_get("default_firstday", 0);
// Last day of week
($weekstart - 1 == -1) ? $lastday = 6 : $lastday = $weekstart - 1;
// Generate the days of the week:
$firstcolumn = mktime(0, 0, 0, 3, 20 + $weekstart, 1994);
$output .= " <tr class=\"header-week\">";
for ($i = 0; $i < 7; $i++) {
$output .= "<td>". t(substr(ucfirst(date("l", $firstcolumn + $i * 86400)), 0, 2)) ."</td>";
}
$output .= "</tr>\n";
// Initialize temporary variables:
$nday = 1;
$sday = $first;
// Loop through all the days of the month:
while ($nday <= $last) {
// Set up blank days for first week of the month:
if ($first != $weekstart) {
$blankdays = ($first - $weekstart + 7) % 7;
$output .= " <tr class=\"row-week\"><td class=\"day-blank\" colspan=\"$blankdays\">&nbsp;</td>\n";
$first = $weekstart;
}
// Start every week on a new line:
if ($sday == $weekstart) {
$output .= " <tr class=\"row-week\">\n";
}
// Print one cell:
$date = mktime(0, 0, 0, $month, $nday, $year) + $user->timezone;
if (in_array($nday, $days_with_posts)) {
$daytext = l($nday, "archive/$year/$month/$nday");
$dayclass = "day-link";
}
else {
$daytext = "<div>$nday</div>";
$dayclass = "day-normal";
}
if ($date == $requested) {
$output .= " <td class=\"day-selected\">$daytext</td>\n";
}
else if ($date == $start_of_today) {
$output .= " <td class=\"day-today\">$daytext</td>\n";
}
else if ($date > $end_of_today) {
$output .= " <td class=\"day-future\">$daytext</td>\n";
}
else {
$output .= " <td class=\"$dayclass\">$daytext</td>\n";
}
// Start every week on a new line:
if ($sday == $lastday) {
$output .= " </tr>\n";
}
// Update temporary variables:
$sday++;
$sday = $sday % 7;
$nday++;
}
// Complete the calendar:
if ($sday != $weekstart) {
$end = (7 - $sday + $weekstart) % 7;
$output .= " <td class=\"day-blank\" colspan=\"$end\">&nbsp;</td>\n </tr>\n";
}
$output .= "</table></div>\n\n";
cache_set("archive:calendar:$start_of_month", $output, 1);
return $output;
}
function archive_block($op = "list", $delta = 0) {
global $date;
if ($op == "list") {
$blocks[0]["info"] = t("Calendar to browse archives");
return $blocks;
}
else if (user_access("access content")) {
switch ($delta) {
case 0:
$block["subject"] = t("Browse archives");
$block["content"] = archive_calendar();
return $block;
}
}
}
function archive_link($type) {
$links = array();
if ($type == "page" && user_access("access content")) {
$links[] = l(t("archives"), "archive", array("title" => t("Read the older content in our archive.")));
}
return $links;
}
function archive_page() {
global $date, $month, $year, $meta, $user;
$op = $_POST["op"];
$edit = $_POST["edit"];
theme("header");
if (user_access("access content")) {
if ($op == t("Show")) {
$year = $edit["year"];
$month = $edit["month"];
$day = $edit["day"];
}
else {
$year = arg(1);
$month = arg(2);
$day = arg(3);
}
$date = mktime(0, 0, 0, $month, $day, $year) - $user->timezone;
/*
** Prepare the values of the form fields:
*/
$years = array(2000 => "2000", 2001 => "2001", 2002 => "2002", 2003 => "2003", 2004 => "2004", 2005 => "2005");
$months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 => t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December"));
for ($i = 1; $i <= 31; $i++) $days[$i] = $i;
$start = "<div class=\"container-inline\">";
$start .= form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show"));
$start .= "</div>";
theme("box", t("Archives"), form($start));
/*
** Fetch nodes for the selected date, or current date if none
** selected.
*/
if ($year && $month && $day) {
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d ORDER BY created", $date, 0, 20);
while ($nid = db_fetch_object($result)) {
node_view(node_load(array("nid" => $nid->nid)), 1);
}
}
}
else {
message_access();
}
theme("footer");
}
function archive_settings() {
$output .= form_select( t("First day of week"), "default_firstday", variable_get("default_firstday", 0), array(0 => t("Sunday"), 1 => t("Monday"), 2 => t("Tuesday"), 3 => t("Wednesday"), 4 => t("Thursday"), 5 => t("Friday"), 6 => t("Saturday")), t("The first day of the week. By changing this value you choose how the calendar block is rendered."));
return $output;
}
?>
<?php
// $Id$
function block_help($section = "admin/help#block") {
$output = "";
switch ($section) {
case 'admin/help#block':
$output .= "<p>Blocks are the boxes visible in the sidebar(s) of your web site. These are usually generated automatically by modules (e.g. recent forum topics), but you can also create your own blocks using either static HTML or dynamic PHP content.</p>";
$output .= "<p>The sidebar each block appears in depends on both which theme you're using (some are left-only, some right, some both), and on the settings in block management.</p><p>Whether a block is visible in the first place depends on three things:</p><ul><li>It must have its \"enabled\" box checked in block management.</li><li>If it has its \"custom\" box checked in block management, the user must have chosen to display it in their user preferences.</li><li>If the \"path\" field in block management is set, the visitor must be on a page that matches the path specification (more on this later).</li></ul>";
$output .= "<p>The block management screen also lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a <b>weight</b> to each block. Lighter blocks (smaller weight) \"float up\" towards the top of the sidebar. Heavier ones \"sink down\" towards the bottom of it. Once you've positioned things just so, you can preview what the layout will look like in different types of themes by clicking the preview placement link in the menu to the left.</p>";
$output .= "<p>The path setting lets you define the pages on which a specific block is visable. If you leave the path blank it will appear on all pages. The path uses a regular expression syntax so remember to escape special characters!</p>";
$output .= "<p>In case you do not know what a regular expression is, you should read about them in the PHP manual. The chapter to look at is the one on %pcre.</p>";
$output .= "<p>However, for basic tasks it is sufficient to look at the following examples:</p>";
$output .= "<p>If the block should only show up on blog pages, use &lt;/blog&gt;. To display on all node views use &lt;/node/view&gt;. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use &lt;(/forum|/book)&gt;. The round brackets form a group of expressions, divided by the | character. It matches if any of the expressions in it match. A more complicated example is &lt;/node/add/(story|blog|image)&gt;. Blocks which have their paths set to this expression will show up on story, block, or image composition pages. If you want to show a block an all pages, but not the search page, use &lt;(^/$|[^(search)$/]+)&gt;</p>";
$output .= "<h3>Custom Blocks</h3>";
$output .= "<p>A custom block contains admin-supplied HTML, text or PHP content (as opposed to being generated automatically by a module). Each custom block consists of a title, a description, and a body containing text, HTML, or PHP code which can be as long as you wish. The Drupal engine will 'render' the content of the custom block.</p>";
$output .= "<h4>PHP in custom blocks</h4>";
$output .= "<p>If you know how to script in PHP, Drupal gives you the power to embed any script you like inside a block. It will be executed when the page is viewed and dynamically embedded into the page. This gives you amazing flexibility and power, but of course with that comes danger and insecurity if you don't write good code. If you are not familiar with PHP, SQL or with the site engine, avoid experimenting with PHP custom blocks because you can corrupt your database or render your site insecure or even unusable! If you don't plan to do fancy stuff with custom blocks then you're probably better off with straight HTML.</p>";
$output .= "<p>Remember that the code within each PHP custom block must be valid PHP code - including things like correctly terminating statements with a semicolon so that the parser won't die. It is highly recommended that you develop your cusom blocks separately using a simple test script on top of a test database before migrating to your production environment.</p>";
$output .= "<p>Notes:</p><ul><li>You can use global variables, such as configuration parameters, within the scope of a PHP box but remember that variables which have been given values in a PHP box will retain these values in the engine or module afterwards.</li><li>register_globals is now set to <b>off</b> by default. If you need form information you need to get it from the \"superglobals\" \$_POST, \$_GET, etc.</li><li>You can use the <code>return</code> statement to return the actual content for your block as well.</li></ul>";
$output .= "<p>A basic example:</p>";
$output .= "<blockquote><p>You want to have a box with the title \"Welcome\" that you use to greet your visitors. The content for this box could be created by going:</p>";
$output .= "<pre>
return t(\"Welcome visitor, ... welcome message goes here ...\");
</pre>";
$output .= "<p>If we are however dealing with a registered user, we can customize the message by using:</p>";
$output .= "<pre>
if (\$user->uid) {
return t(\"Welcome \$user->name, ... welcome message goes here ...\");
}
else {
return t(\"Welcome visitor, ... welcome message goes here ...\");
}";
$output .= "</pre></blockquote>";
$output .= "<p>For more in-depth examples, we recommend that you check the existing boxes and use them as a starting point.</p>";
$output = t($output, array("%pcre" => "<a href=\"http://php.net/pcre/\">". t("Perl-Compatible Regular Expressions (PCRE)") ."</a>"));
break;
case 'admin/system/modules#description':
$output = t("Controls the boxes that are displayed around the main content.");
break;
case 'admin/system/block':
$output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <b>active</b> Drupal modules. In order to view a block it must be enabled. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. The custom checkbox lets your users hide the block using their account setting. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the %createblock link in the menu to the left. Edit and delete links will become active below for these customized blocks.", array("%createblock" => l(t("new block"), "admin/system/block/add")));
break;
case 'admin/system/block/add':
$output = t("Here you can create a custom content block. Once you have created this block you must make it active, and give it a place on the page using %overview. The title is used when displaying the block. The description is used in the \"block\" column on the %overview page. If you are going to place PHP code in the block, and you have <b>create php content</b> permission (see the %permission page) you <b>must</b> change the type to PHP to make your code active.", array("%overview" => l(t("blocks"), "admin/system/block"), "%permission" => l(t("permissions"), "admin/user/permission")));
break;
case 'admin/system/block/preview':
$output = t("This page show you the placement of your blocks in different themes types. The numbers are the weight of each block, which is used to sort them within the sidebars.");
break;
}
return $output;
}
function block_perm() {
return array("administer blocks");
}
function block_link($type) {
if ($type == "system" && user_access("administer blocks")) {
menu("admin/system/block", t("blocks"), "block_admin", 3);
menu("admin/system/block/add", t("new block"), "block_admin", 2);
menu("admin/system/block/preview", t("preview placement"), "block_admin", 3);
menu("admin/system/block/help", t("help"), "block_help", 9);
}
}
function block_block($op = "list", $delta = 0) {
if ($op == "list") {
$result = db_query("SELECT bid, title, info FROM {boxes} ORDER BY title");
while ($block = db_fetch_object($result)) {
$blocks[$block->bid]["info"] = $block->info;
}
return $blocks;
}
else {
$block = db_fetch_object(db_query("SELECT * FROM {boxes} WHERE bid = %d", $delta));
$data["subject"] = $block->title;
$data["content"] = ($block->type == 1) ? eval($block->body) : $block->body;
return $data;
}
}
function block_admin_save($edit) {
foreach ($edit as $module => $blocks) {
foreach ($blocks as $delta => $block) {
db_query("UPDATE {blocks} SET region = %d, status = %d, custom = %d, path = '%s', weight = %d WHERE module = '%s' AND delta = '%s'",
$block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
}
}
return t("the block settings have been updated.");
}
/**
* update blocks db table with blocks currently exported by modules
*
* @param array $order_by php array_multisort() style sort ordering, eg. "weight", SORT_ASC, SORT_STRING. see {@link http://www.php.net/manual/en/function.array-multisort.php}
* @return array blocks currently exported by modules, sorted by $order_by
* @access private
*/
function _block_rehash($order_by = array("weight")) {
$result = db_query("SELECT * FROM {blocks} ");
while ($old_block = db_fetch_object($result)) {
$old_blocks[$old_block->module][$old_block->delta] = $old_block;
}
db_query("DELETE FROM {blocks} ");
foreach (module_list() as $module) {
$module_blocks = module_invoke($module, "block", "list");
if ($module_blocks) {
foreach ($module_blocks as $delta => $block) {
$block["module"] = $module;
$block["delta"] = $delta;
if ($old_blocks[$module][$delta]) {
$block["status"] = $old_blocks[$module][$delta]->status;
$block["weight"] = $old_blocks[$module][$delta]->weight;
$block["region"] = $old_blocks[$module][$delta]->region;
$block["path"] = $old_blocks[$module][$delta]->path;
$block["custom"] = $old_blocks[$module][$delta]->custom;
}
else {
$block["status"] = $block["weight"] = $block["region"] = $block["custom"] = 0;
$block["path"] = "";
}
// reinsert blocks into table
db_query("INSERT INTO {blocks} (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)",
$block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
$blocks[] = $block;
// build array to sort on
$order[$order_by[0]][] = $block[$order_by[0]];
}
}
}
// sort
array_multisort($order[$order_by[0]], $order_by[1] ? $order_by[1] : SORT_ASC, $order_by[2] ? $order_by[2] : SORT_REGULAR, $blocks);
return $blocks;
}
function block_admin_display() {
$blocks = _block_rehash();
$header = array(t("block"), t("enabled"), t("custom"), t("weight"), t("region"), t("path"), array("data" => t("operations"), "colspan" => 2));
foreach ($blocks as $block) {
if ($block["module"] == "block") {
$edit = l(t("edit"), "admin/system/block/edit/". $block["delta"]);
$delete = l(t("delete"), "admin/system/block/delete/". $block["delta"]);
}
else {
$edit = "";
$delete = "";
}
$rows[] = array($block["info"], array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]), "align" => "center"), array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]), "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array(t("left"), t("right"))), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
}
$output = table($header, $rows);
$output .= form_submit(t("Save blocks"));
return form($output);
}
function block_admin_preview() {
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 AND region = 0 ORDER BY weight");
$lblocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
$name = $block_data[$block->delta]["info"];
$lblocks .= " <tr><td>". ($block->status == 2 ? "<b>$name</b>" : $name) ."</td><td>$block->weight</td></tr>\n";
}
$lblocks .= "</table>\n";
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 AND region = 1 ORDER BY weight");
$rblocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
$name = $block_data[$block->delta]["info"];
$rblocks .= " <tr><td>". ($block->status == 2 ? "<b>$name</b>" : $name) ."</td><td>$block->weight</td></tr>\n";
}
$rblocks .= "</table>\n";
$output .= "<h3>". t("Themes with both left and right sidebars") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td>\n". ($lblocks ? $lblocks : "&nbsp;") ."</td><td style=\"width: 300px;\">&nbsp;</td><td>\n". ($rblocks ? $rblocks : "&nbsp;") ."</td></tr>\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
$result = db_query("SELECT * FROM {blocks} WHERE status > 0 ORDER BY weight");
$blocks .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
while ($block = db_fetch_object($result)) {
$block_data = module_invoke($block->module, "block", "list");
$name = $block_data[$block->delta]["info"];
$blocks .= " <tr><td>". ($block->status == 2 ? "<b>$name</b>" : $name) ."</td><td>$block->weight</td></tr>\n";
}
$blocks .= "</table>\n";
$output .= "<h3>". t("Themes with right-sidebar only") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td style=\"width: 400px;\">&nbsp;</td><td>\n". ($blocks ? $blocks : "&nbsp;") ."</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
$output .= "<h3>". t("Themes with left-sidebar only") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td>\n". ($blocks ? $blocks : "&nbsp;") ."</td><td style=\"width: 400px;\">&nbsp;</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
return $output;
}
function block_box_get($bid) {
return db_fetch_array(db_query("SELECT * FROM {boxes} WHERE bid = %d", $bid));
}
function block_box_form($edit = array()) {
$type = array(0 => "HTML", 1 => "PHP");
$form = form_textfield(t("Title"), "title", $edit["title"], 50, 64);
$form .= form_textfield(t("Description"), "info", $edit["info"], 50, 64);
$form .= form_textarea(t("Body"), "body", $edit["body"], 70, 10);
if (user_access("create php content")) {
$form .= form_select(t("Type"), "type", $edit["type"], $type);
}
if ($edit["bid"]) {
$form .= form_hidden("bid", $edit["bid"]);
}
$form .= form_submit(t("Save block"));
return form($form);
}
function block_box_save($edit) {
if (!user_access("create php content")) {
$edit["type"] = 0;
}
if ($edit["bid"]) {
db_query("UPDATE {boxes} SET title = '%s', body = '%s', info = '%s', type = %d WHERE bid = %d", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
return t("the block has been updated.");
}
else {
db_query("INSERT INTO {boxes} (title, body, info, type) VALUES ('%s', '%s', '%s', %d)", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
return t("the new block has been added.");
}
}
function block_box_delete($bid) {
if ($bid) {
db_query("DELETE FROM {boxes} WHERE bid = %d", $bid);
return t("the block has been deleted.");
}
}
function block_admin() {
$op = $_POST["op"];
$edit = $_POST["edit"];
if (user_access("administer blocks")) {
if (empty($op)) {
$op = arg(3);
}
switch ($op) {
case "preview":
$output = block_admin_preview();
break;
case "add":
$output = block_box_form();
break;
case "edit":
$output = block_box_form(block_box_get(arg(4)));
break;
case "delete":
$output = status(block_box_delete(arg(4)));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save block"):
$output = status(block_box_save($edit));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save blocks"):
$output = status(block_admin_save($edit));
cache_clear_all();
// fall through
default:
$output .= block_admin_display();
}
return $output;
}
else {
return message_access();
}
}
function block_user($type, &$edit, &$user) {
switch ($type) {
case "register_form":
$result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$form .= form_hidden("block][$block->module][$block->delta", $block->status);
}
return $form;
case "edit_form":
$result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
if ($data[$block->delta]["info"]) {
$form .= "<tr><td>". $data[$block->delta]["info"] ."</td><td>". form_checkbox(NULL, "block][$block->module][$block->delta", 1, $user->block[$block->module][$block->delta]) ."</td></tr>\n";
}
}
if (isset($form)) {
return form_item(t("Block configuration"), "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">". $form ."</table>", t("Enable the blocks you would like to see displayed in the side bars."));
}
break;
case "edit_validate":
if (!$edit["block"]) {
$edit["block"] = array();
}
return $edit;
}
}
?>
<?php
// $Id$
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."));
$words = t("words");
$output .= form_select(t("Minimum number of words in a blog entry"), "minimum_blog_size", variable_get("minimum_blog_size", 0), array(0 => "0 $words", 10 => "10 $words", 25 => "25 $words", 50 => "50 $words", 75 => "75 $words", 100 => "100 $words", 125 => "125 $words", 150 => "150 $words", 175 => "175 $words", 200 => "200 $words"), 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;
}
function blog_node($field) {
global $user;
$info["name"] = t("personal blog entry");
$info["description"] = 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 $info[$field];
}
function blog_perm() {
return array("maintain personal blog");
}
function blog_access($op, $node) {
global $user;
if ($op == "view") {
return $node->status;
}
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 == "delete") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
}
}
function blog_head($main = 0) {
$mod = arg(0);
$id = arg(1);
$output = array();
if ($mod == "blog") {
$output[] = "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS feed\" href=\"". url("blog/feed/$id") ."\" />";
}
return $output;
}
function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
if (user_access("maintain personal blog", $user)) {
return 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)))));
}
}
}
function blog_help($section) {
$output ="";
switch ($section) {
case 'admin/help#blog':
$output .= "<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>";
$output .= "<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>";
$output .= "<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>";
$output .= "<p>If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link <b>(b)</b> 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>";
$output = t($output, array("%scripting-com" => "<a href=\"http://www.scripting.com/\">http://www.scripting.com/</a>" ));
break;
case 'admin/system/modules#description':
$output .= t("Enables keeping a blog or easily and regularly updated web page.");
break;
case 'admin/system/modules/blog':
$output .= t("A weBLOG is a running journal of a users ideas. Enter the minimum word count for a single entry, and the text displayed on the entry submission form");
break;
}
return $output;
}
function blog_feed_user($uid = 0) {
global $user;
if ($uid) {
$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");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
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;
node_feed($result, $channel);
}
function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? "uid" : "name") => $uid, "status" => 1));
// Breadcrumb navigation:
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = l(t("Blogs"), "blog");
$breadcrumb[] = t("%name's blog", array("%name" => $account->name));
theme("breadcrumb", $breadcrumb);
$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)) {
node_view(node_load(array("nid" => $node->nid)), 1);
}
print pager_display(NULL, variable_get("default_nodes_main", 10));
print "<div style=\"text-align: right\">" . l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed/$account->uid", array("title" => t("View the XML version of %username's blog", array("%username" => $account->name)))) . "</div>";
}
function blog_page_last() {
global $user;
// Breadcrumb navigation:
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = t("Blogs");
theme("breadcrumb", $breadcrumb);
$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)) {
node_view(node_load(array("nid" => $node->nid)), 1);
}
print pager_display(NULL, variable_get("default_nodes_main", 10));
print "<div style=\"text-align: right;\">". l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed", array("title" => t("Read the XML version of all blogs."))) ."</div>";
}
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("theme_error", t("The body of your blog is too short."));
}
return $error;
}
function blog_form(&$node, &$help, &$error) {
global $nid;
$iid = $_GET["iid"];
/*
** Carry out some explanation or submission guidelines:
*/
$help = variable_get("blog_help", "");
if (empty($node->body)) {
/*
** If the user clicked a "blog it" link, we load the data from the
** 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 ($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));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : form_allowed_tags_text());
return $output;
}
function blog_page() {
if (user_access("access content")) {
switch (arg(1)) {
case "feed":
if (arg(2)) {
blog_feed_user(arg(2));
}
else {
blog_feed_last();
}
break;
default:
theme("header");
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
theme("footer");
}
}
else {
theme("header");
theme("box", t("Access denied"), message_access());
theme("footer");
}
}
function blog_content($node) {
$node->teaser = check_output($node->teaser);
$node->body = check_output($node->body);
return $node;
}
function blog_view($node, $main = 0) {
if ($main == 0) {
// Breadcrumb navigation
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = l(t("%name's blog", array("%name" => $node->name)), "blog/$node->uid");
// print the breadcrumb
theme("breadcrumb", $breadcrumb);
}
// prepair the node content
$node = blog_content($node);
// print the node
theme("node", $node, $main);
}
function blog_link($type, $node = 0, $main) {
global $user;
$links = array();
if ($type == "system") {
if (user_access("maintain personal blog")) {
menu("node/add/blog", t("blog entry"), "blog_page", 0);
}
if (user_access("maintain personal blog")) {
menu("blog/" . $user->uid, t("my blog"), "user_page", 1);
}
}
if ($type == "page" && user_access("access content")) {
$links[] = l(t("blogs"), "blog", array("title" => t("Read the latest blog entries.")));
}
if ($type == "node" && $node->type == "blog") {
global $mod, $op, $id;
if (blog_access("update", $node)) {
$links[] = l(t("edit this blog entry"), "node/edit/$node->nid", array("title" => t("Edit this blog entry.")));
}
elseif (empty($id)) {
$links[] = l(t("%username's blog", array("%username" => $node->name)), "blog/$node->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $node->name))));
}
}
return $links;
}
function blog_block($op = "list", $delta = 0) {
global $user;
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");
}
return $block;
}
}
?>
This diff is collapsed.
This diff is collapsed.
<?php
// $Id$
function drupal_help($section = "admin/help#drupal") {
$output = "";
switch ($section) {
case 'admin/help#drupal':
$output .= "<p>The \"Drupal\" module features a capability whereby other drupal sites may <i>call home</i> to report their existence. In turn, this enables a pod of Drupal sites to find, cooperate and advertise each other.</p>";
$output .= "<p>Currently, the main application of this feature is the %drupal-sites. By default, fresh Drupal installations can use %Drupal as their <i>directory server</i> and report their existence. This reporting occurs via scheduled %xml-rpc pings.</p>";
$output .= "<p>Drupal administrators should simply enable this feature to get listed on the %drupal-sites; just set your site's name, e-mail address, slogan and mission statement. Then make sure that the field called <i>Drupal XML-RPC server</i> on the %drupal-settings page is set to http://www.drupal.org/xmlrpc.php, and enable this feature using the dropdown directly below.</p>";
$output .= "<p>The listing of your site will occur shortly after your site's next %cron. Note that cron.php should be called using the domain name which you want to have listed at %Drupal. For example, don't kick off cron by requesting http://127.0.0.1/cron.php. Instead, use a publicly accessible domain name such as http://www.mydomain.org/cron.php.</p>";
$output .= "<p>Also note that your installation need not use drupal.org as its directory server. For example, this feature is perfectly capable of aggregating pings from all of your departmental drupal installations sites within an enterprise.</p>";
$output = t($output, array("%drupal-sites" => "<a href=\"http://www.drupal.org/node/view/3\">". t("Drupal sites page") ."</a>", "%Drupal" => "<a href=\"http://www.drupal.org\">drupal.org</a>", "%xml-rpc" => "<a href=\"http://www.xmlrpc.com/\">XLM-RPC</a>", "%drupal-settings" => l(t("administer") ." &raquo; ". t("configuration") ." &raquo; ". t("modules") ." &raquo; ". t("drupal"), "admin/system/modules/drupal"), "%cron" => l(t("cron run"), "admin/system/help#cron")));
break;
case 'admin/system/modules#description':
$output = t("Lets users log in using a Drupal ID and can notify drupal.org about your site.");
break;
case 'admin/system/modules/drupal':
$output = t("Using this your Drupal site can \"call home\" and add itself to the Drupal directory. If you want it to add itself to a different directory server you can change the %Drupal-setting setting -- but the directory server has to be able to handle Drupal XML. To get a full site listing go to the %general and set:<ul><li>The site name,</li><li>The site E-Mail address,</li><li>The site slogan, and</li><li>The site mission statement.</li></ul>", array("%Drupal-setting" => l(t("Drupal XML-RPC server"), "admin/system/modules/drupal"), "%general" => l(t("site configuration"), "admin/system")));
break;
case 'user/help#drupal':
$site = variable_get("site_name", "this web site");
$output = "<p>%drupal is the name of the software which powers %site. There are Drupal web sites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single <b>Drupal ID</b>.</p>\n";
$output .= "<p>So please feel free to login to your account here at %site with a username from another Drupal site. The format of a Drupal ID is similar to an email address: <b>username</b>@<i>server</i>. An example of valid Drupal ID is <b>mwlily</b>@<i>www.drupal.org</i>.</p>";
$output = t($output, array("%drupal" => "<a href=\"http://www.drupal.org\">Drupal</a>", "%site" => "<i>$site</i>"));
break;
}
return $output;
}
function drupal_settings() {
$output .= form_textfield("Drupal XML-RPC server", "drupal_server", variable_get("drupal_server", "http://www.drupal.org/xmlrpc.php"), 55, 128, "The URL of your root Drupal XML-RPC server.");
$output .= form_select("Drupal directory", "drupal_directory", variable_get("drupal_directory", 0), array("Disabled", "Enabled"), "If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you have to set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"http://www.drupal.org/xmlrpc.php\", your web site will get listed on <a href=\"http://www.drupal.org/\">http://www.drupal.org/</a>. Requires crontab.");
return $output;
}
function drupal_cron() {
if (time() - variable_get("drupal_cron_last", 0) > 21600) {
variable_set("drupal_cron_last", time());
/*
** If this site acts as a Drupal XML-RPC server, delete the sites that
** stopped sending "ping" messages.
*/
db_query("DELETE FROM {directory} WHERE timestamp < '". (time() - 259200) ."'");
/*
** If this site acts as a Drupal XML-RPC client, send a message to the
** Drupal XML-RPC server.
*/
if (variable_get("drupal_directory", 0) && variable_get("drupal_server", 0)) {
drupal_notify(variable_get("drupal_server", ""));
}
}
}
function drupal_directory_ping($arguments) {
/*
** Parse our parameters:
*/
$argument = $arguments->getparam(0);
$link = strip_tags($argument->scalarval());
$argument = $arguments->getparam(1);
$name = strip_tags($argument->scalarval());
$argument = $arguments->getparam(2);
$mail = strip_tags($argument->scalarval());
$argument = $arguments->getparam(3);
$slogan = strip_tags($argument->scalarval());
$argument = $arguments->getparam(4);
$mission = strip_tags($argument->scalarval());
/*
** Update the data in our database and send back a reply:
*/
if ($link && $name && $mail && $slogan && $mission) {
db_query("DELETE FROM {directory} WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO {directory} (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $link, $name, $mail, $slogan, $mission, time());
watchdog("message", "directory: ping from '$name' ($link)");
return new xmlrpcresp(new xmlrpcval(1, "int"));
}
else {
return new xmlrpcresp(new xmlrpcval(0, "int"));
}
}
function drupal_directory_page() {
$result = db_query("SELECT * FROM {directory} ORDER BY name");
while ($site = db_fetch_object($result)) {
$output .= "<a href=\"$site->link\">$site->name</a> - $site->slogan<div style=\"padding-left: 20px;\">$site->mission</div><br />";
}
return $output;
}
function drupal_xmlrpc() {
return array("drupal.site.ping" => array("function" => "drupal_directory_ping"), "drupal.login" => array("function" => "drupal_login"));
}
function drupal_notify($server) {
global $base_url;
$url = parse_url($server);
$client = new xmlrpc_client($url["path"], $url["host"], 80);
$message = new xmlrpcmsg("drupal.site.ping", array(new xmlrpcval($base_url, "string"), new xmlrpcval(variable_get("site_name", ""), "string"), new xmlrpcval(variable_get("site_mail", ""), "string"), new xmlrpcval(variable_get("site_slogan", ""), "string"), new xmlrpcval(variable_get("site_mission", ""), "string")));
$result = $client->send($message, 5);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify '". $url["host"] ."' at '". $url["path"] ."': ". $result->faultString());
}
}
function drupal_info($field = 0) {
$info["name"] = "Drupal";
$info["protocol"] = "XML-RPC";
if ($field) {
return $info[$field];
}
else {
return $info;
}
}
function drupal_auth($username, $password, $server) {
$message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string")));
// TODO remove hard coded Port 80
// TODO manage server/path such that HTTP_HOST/xml.rpc.php is not assumed
$client = new xmlrpc_client("/xmlrpc.php", $server, 80);
$result = $client->send($message, 5);
if ($result && !$result->faultCode()) {
$value = $result->value();
$login = $value->scalarval();
}
return $login;
}
function drupal_page() {
theme("header");
theme("box", "Drupal", drupal_help("user/help#drupal"));
theme("footer");
}
function drupal_login($arguments) {
// an XML-RPC method called by external clients (usually other Drupal instances)
$argument = $arguments->getparam(0);
$username = $argument->scalarval();
$argument = $arguments->getparam(1);
$password = $argument->scalarval();
if ($user = user_load(array(name => "$username", "pass" => $password, "status" => 1))) {
return new xmlrpcresp(new xmlrpcval($user->uid, "int"));
}
else {
return new xmlrpcresp(new xmlrpcval(0, "int"));
}
}
function drupal_user($type, $edit, $user) {
$module = "drupal";
$name = module_invoke($module, "info", "name");
switch ($type) {
case "view_private":
$result = user_get_authname($user, $module);
if ($result) {
$output .= form_item(t("$name ID"), $result);
}
else {
// TODO: use a variation of $base_url instead of $HTTP_HOST below
$output .= form_item(t("$name ID"), "$user->name@". $_SERVER["HTTP_HOST"]);
}
return $output;
}
}
?>
This diff is collapsed.
<?php
// $Id$
function help_link($type) {
if ($type == "system" && user_access("access administration pages")) {
menu("admin/help/glossary", t("glossary"), "help_glossary", 8);
menu("admin/help", t("help"), "help_help", 9);
}
}
function help_glossary() {
$output .= "<h3>Glossary</h3><dl>";
$output .= "<dt>Block</dt><dd>A small box containing information or content placed in the left-hand or right-hand sidebar of a web page.</dd>";
$output .= "<dt>Comment</dt><dd>A note attached to a node. Usually intended to clarify, explain, criticize, or express an opinion on the original material.</dd>";
$output .= "<dt>Moderation</dt><dd>The activity of making sure a post to a Drupal site fits in with what is expected for that Drupal site.<dl>";
$output .= "<dt>Approved</dt><dd>A moderated post which has been accepted by the moderators for publication. (See published).</dd>";
$output .= "<dt>Waiting</dt><dd>A moderated post which is still being voted on to be accepted for publication. (See published.)</dd>";
$output .= "<dt>Moderators</dt><dd>The group of Drupal users that reviews posts before they are published. These users have the \"access submission queue\" permission. (See Published).</dd></dl></dd>";
$output .= "<dt>Node</dt><dd>The basic data unit in Drupal. Everything is a node or an extention of a node.</dd>";
$output .= "<dt>Public</dt><dd>See published.</dd>";
$output .= "<dt>Published</dt><dd>A node that is viewable by everyone. (See unpublished.)</dd>";
$output .= "<dt>Role</dt><dd>A classification users are placed into for the purpose of setting users' permissions.</dd>";
$output .= "<dt>Taxonomy</dt><dd>A division of a collection of things into ordered, classified groups. (See %taxonomy.)</dd>";
$output .= "<dt>Unpublished</dt><dd>A node that is only viewable by administrators and moderators.</dd>";
$output .= "<dt>User</dt><dd>A person who has an account at your Drupal site, and is logged in with that account.</dd>";
$output .= "<dt>Visitor</dt><dd>A person who does not have an account at your Drupal site or a person who has an account at your Drupal site but is <u>not</u> logged in with that account. Also termed \"anonymous user\".</dd>";
$output .= "</dl>";
$output = t($output, array("%taxonomy" => l(t("taxonomy help"), "admin/taxonomy/help")));
return $output;
}
function help_help($section = "admin/help#help") {
$output = "";
switch ($section) {
case 'admin/help#help':
foreach (module_list() as $name) {
if ($name == 'help') {
continue;
}
else if (module_hook($name, "help")) {
$temp = module_invoke($name, "help", "admin/help#$name");
if (!empty($temp)) {
$links[] = l($name, "admin/help#$name");
$output .= "<h2><a id=\"$name\">". ucfirst($name) ." module</a></h2>";
$output .= $temp;
}
}
}
$output = "<small>". implode(" &middot; ", $links) ."</small><hr />". $output;
break;
case 'admin/system/modules#description':
$output = t("Manages displaying online help.");
break;
}
return $output;
}
?>
<?php
// $Id$
function locale_help($section = "admin/help#locale") {
$output = "";
switch ($section) {
case 'admin/help#locale':
$output .= "<p>Most programs are written and documented in English, and use English to interact with users. This is also true for a great deal of web sites. However, most people are less comfortable with English than with their native language, and would prefer to use their mother tongue as much as possible. Many people love see their web site showing a lot less English, and far more of their own language.</p>";
$output .= "<p>Therefore Drupal provides a framework to setup a multi-lingual web site, or to overwrite the default English texts. We explored the various alternatives to support internationalization (I18N) and decided to design the framework in such a way that the impact of internationalization on drupal's sources is minimized, modular and doesn't require a HTML or PHP wizard to maintain translations. Maintaining translations had to be simple so it became as easy as filling out forms on the administration page.</p>";
$output .= "<h3>How to translate texts</h3>";
$output .= "<p>The actual translation starts at the %overview page of the locale section in the administration pages. In the menu on the left under \"localization\" you will see a list of the languages you have configured. Click on the name of the language to start translating. Looking at a page full of all the strings in the site can be a bit overwhelming, so Drupal allows you to limit the strings you are working on. If you want to limit based on translated strings click \"translated strings\", if you want to limit the string based on the untranslated strings click \"untranslated strings\". Both will take you to the same page. Once there enter the string pattern to limit on, choose the language to search for, and the status, weather translated, untranslated or both, finally where you want to look, modules, specific modules, or pages.</p>";
$output .= "<p>At the locale page, users with the proper access rights will see the various texts that need translation on the left column of the table.</p>";
$output .= "<p>Below the text you can see an example URI where this text shows up one your site. Chances are most of these texts will be used and displayed on more than one page, though only one example URI is presented.</p>";
$output .= "<p>The second column displays the supported languages as defined in the configuration file. See below for more information on how to support new languages. If the symbol for a language is seen like <strike>this</strike>, it means that this entry still needs to be translated into that language. If not, it has been translated already.</p>";
$output .= "<p>To add or change a translation click the \"edit locale\" link in the third column, the \"operations\" column. You'll be presented the original text and fields for translation in the supported languages. Enter the translations and confirm by clicking the \"Save translations\" button. The translations need not be accurate; they are for your site so you can choose what to show to your users.</p>";
$output .= "<p>To delete a translation, click the \"delete locale\" link at the overview page and the translation will be immediately deleted without confirmation. Deleting translations is convenient for removing texts that belonged to an obsolete module.</p>";
$output .= "<p>In some texts special strings such as \"%a\" and \"%b\" show up. Those get replaced by some string at run-time when Drupal dynamically generate pages. You can find out which string this is by looking at the page where the text appears. This is where the above mentioned URI can come in handy.</p>";
$output .= "<h3>How to add new languages</h3>";
$output .= "<p>Adding a new language requires you to edit your configuration file and your SQL database. Assuming you want to support Dutch (ISO 639 code: \"nl\") and French (ISO 639 code: \"fr\"), you add the following line to your configuration file's <code>\$languages</code>-variable:</p>";
$output .= "<pre>
\$languages = array(\"nl\" => \"Dutch / Nederlands\", \"fr\" => \"French / Francais\");
</pre>";
$output .= "<p>Note that the default language must come first and that if you want to overwrite the default text you can add an entry for English (ISO 639 code: \"en\"):</p>";
$output .= "<pre>
\$languages = array(\"en\" => \"English\", \"nl\" => \"Dutch / Nederlands\", \"fr\" => \"French / Francais\");
</pre>";
$output .= "<p>After having edited your configuration file, make sure your SQL table \"locales\" has the required database fields setup to host your new translations. You can add the required rows to your \"locales\" table from the MySQL prompt:</p>";
$output .= "<pre>
mysql> ALTER TABLE {locales} ADD en TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE {locales} ADD nl TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE {locales} ADD fr TEXT DEFAULT '' NOT NULL;
</pre>";
$output = t($output, array("%overview" => l(t("overview"), "admin/locale")));
break;
case 'admin/system/modules#description':
$output = t("Enables the translation of the user interface to languages other than English.");
break;
case 'admin/locale':
$output = t("The locale module handles translations into new languages. It also enables you to add jargon, slang or other special language as fits the web site. For each language you want to support, a line needs to be added to your configuration file.");
break;
case 'admin/locale/search':
$output = t("Search the localization database. ('*' can be used as a wildcard)");
break;
case 'admin/locale/translated':
$output = t("Start by searching the translated strings.");
break;
case 'admin/locale/untranslated':
$output = t("Start by searching the untranslated strings.");
break;
}
return $output;
}
function locale_perm() {
return array("administer locales");
}
function locale_link($type) {
global $languages;
if ($type == "system") {
if (user_access("administer locales")) {
menu("admin/locale", t("localization"), NULL, 5);
menu("admin/locale/search", t("search string"), "locale_admin", 8);
menu("admin/locale/help", t("help"), "locale_help", 9);
menu("admin/locale/edit", t("edit string"), "locale_admin", 0, 1); // hidden menu
menu("admin/locale/delete", t("delete string"), "locale_admin", 0, 1); // hidden menu
foreach ($languages as $key => $value) {
menu("admin/locale/$key", "$value", NULL);
menu("admin/locale/$key/translated", t("translated strings"), "locale_admin");
menu("admin/locale/$key/untranslated", t("untranslated strings"), "locale_admin");
}
}
}
}
function locale_user($type, &$edit, &$user) {
global $languages;
if ($type == "edit_form" && count($languages) > 1) {
$output = form_select(t("Language"), "language", $user->language, $languages, t("Selecting a different language will change the language of the site."));
}
return $output;
}
function locale_delete($lid) {
db_query("DELETE FROM {locales} WHERE lid = %d", $lid);
locale_refresh_cache();
return t("deleted string");
}
function locale_save($lid) {
$edit =& $_POST["edit"];
foreach ($edit as $key=>$value) {
db_query("UPDATE {locales} SET $key = '%s' WHERE lid = %d", $value, $lid);
}
locale_refresh_cache();
// delete form data so it will remember where it came from
$edit = '';
return t("saved string");
}
function locale_refresh_cache() {
global $languages;
foreach (array_keys($languages) as $locale) {
$result = db_query("SELECT string, %s FROM {locales} ", $locale);
while ($data = db_fetch_object($result)) {
if (empty($data->$locale)) {
$t[$data->string] = $data->string;
}
else {
$t[$data->string] = $data->$locale;
}
}
cache_set("locale:$locale", serialize($t));
}
}
function locale_edit($lid) {
global $languages;
$result = db_query("SELECT * FROM {locales} WHERE lid = '$lid'");
if ($translation = db_fetch_object($result)) {
$form .= form_item(t("Original text"), wordwrap(drupal_specialchars($translation->string, 0)));
foreach ($languages as $code=>$language) {
$form .= (strlen($translation->string) > 30) ? form_textarea($language, $code, $translation->$code, 50, 10) : form_textfield($language, $code, $translation->$code, 50, 128);
}
$form .= form_submit(t("Save translations"));
return form($form);
}
}
function locale_languages($translation) {
global $languages;
foreach ($languages as $key => $value) {
$output .= ($translation->$key) ? "<a href=\"#\" title=\"". $translation->$key ."\">$key</a> " : "<strike>$key</strike> ";
}
return $output;
}
function locale_seek_query() {
$fields = array("string", "language", "status");
if (is_array($_REQUEST["edit"])) {
foreach ($_REQUEST["edit"] as $key => $value) {
if (!empty($value) && in_array($key, $fields)) {
$query->$key = $value;
}
}
}
else {
foreach ($_REQUEST as $key => $value) {
if (!empty($value) && in_array($key, $fields)) {
$query->$key = strpos(",", $value) ? explode(",", $value) : $value;
}
}
}
return $query;
}
function locale_seek() {
global $id, $languages;
$op = $_POST["op"];
$query = locale_seek_query();
if ($query) {
if ($query->status) {
switch ($query->language) {
case "all":
foreach ($languages as $key=>$value) {
$tmp[] = $key . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
}
$sql[] = implode(" AND ", $tmp);
break;
case "any":
foreach ($languages as $key=>$value) {
$tmp[] = $key . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
}
$sql[] = "(". implode(" || ", $tmp) .")";
break;
default:
$sql[] = check_query($query->language) . (check_query($query->status) == 1 ? " !=" : " =") ." ''";
}
}
if ($query->string) {
$string_query[] = "string LIKE '%". check_query($query->string) ."%'";
if ($query->status != 2) {
if (strlen($query->language) == 2) {
$string_query[] = check_query($query->language) ." LIKE '%". check_query($query->string) ."%'";
}
else {
foreach ($languages as $key=>$value) {
$string_query[] = check_query($key) ." LIKE '%". check_query($query->string) ."%'";
}
}
}
$sql[] = "(". implode(" || ", $string_query) .")";
}
$result = pager_query("SELECT * FROM {locales} ". (count($sql) ? " WHERE ". implode(" && ", $sql) : "") ." ORDER BY string", 50);
$header = array(t("string"), (($query->status != 2 && strlen($query->language) == 2) ? t("translated string") : t("languages")), array("data" => t("operations"), "colspan" => "2"));
while ($locale = db_fetch_object($result)) {
$rows[] = array("$locale->string<br /><small><i>$locale->location</i></small>", array("data" => (($query->status != 2 && strlen($query->language) == 2) ? $locale->{$query->language} : locale_languages($locale)), "align" => "center"), array("data" => l(t("edit locale"), "admin/locale/edit/$locale->lid"), "nowrap" => "nowrap"), array("data" => l(t("delete locale"), "admin/locale/delete/$locale->lid"), "nowrap" => "nowrap"));
}
$request = array();
if (count($query)) {
foreach ($query as $key => $value) {
$request[$key] = (is_array($value)) ? implode(",", $value) : $value;
}
}
if ($pager = pager_display(NULL, 50, 0, "admin", $request)) {
$rows[] = array(array("data" => "$pager", "colspan" => "5"));
}
$output .= table($header, $rows);
}
return $output;
}
function locale_seek_form() {
global $languages;
$edit =& $_POST["edit"];
$form .= form_textfield(t("Strings to search for"), "string", $edit["string"], 30, 30, t("Leave blank to show all strings."));
$form .= form_select(t("Language"), "language", ($edit["language"] ? $edit["language"] : key($languages)), array_merge(array("any" => t("Any language"), "all" => t("All languages")), $languages), t("In which language must the string be translated/untranslated (see status)?"));
$form .= form_select(t("Status"), "status", $edit["status"], array(2 => t("Untranslated"), 1 => t("Translated"), 0 => t("All")));
$form .= form_submit(t("Search"));
$output .= form($form);
return $output;
}
function locale_admin() {
$op = $_POST["op"];
$edit =& $_POST["edit"];
if (user_access("administer locales")) {
locale_admin_initialize();
if (empty($op)) {
$op = arg(2);
}
switch ($op) {
case "delete":
$output = status(locale_delete(check_query(arg(3))));
$output .= locale_seek();
break;
case "edit":
$output = locale_edit(check_query(arg(3)));
break;
case "search":
if (locale_seek_query()) {
$output = locale_seek();
}
$output .= locale_seek_form();
break;
case t("Search"):
$output = locale_seek();
$output .= locale_seek_form();
break;
case t("Save translations"):
$output = status(locale_save(check_query(arg(3))));
$output .= locale_seek();
break;
default:
if (arg(3) == "translated") {
$edit["status"] = 1;
$edit["language"] = arg(2);
}
else {
$edit["status"] = 2;
$edit["language"] = arg(2);
}
$output = locale_seek();
$output .= locale_seek_form();
}
return $output;
}
else {
return message_access();
}
}
function locale_admin_initialize() {
/*
** This function inserts common strings into the locale table (eg.
** names of months and days). We use $revision and a stored variable
** to track if the locale table is up-to-date.
*/
$revision = 1;
if (variable_get("locale_initialize_revision", 0) < $revision) {
variable_set("locale_initialize_revision", $revision);
for ($i = 1; $i <= 12; $i++) {
$stamp = mktime(0, 0, 0, $i, 1, 1971);
t(date("F", $stamp));
t(date("M", $stamp));
}
for ($i = 0; $i <= 7; $i++) {
$stamp = $i * 86400;
t(date("D", $stamp));
t(date("l", $stamp));
}
}
}
function locale($string) {
global $locale;
static $locale_t;
if (!isset($locale_t)) {
$cache = cache_get("locale:$locale");
if ($cache == 0) {
locale_refresh_cache();
$cache = cache_get("locale:$locale");
}
$locale_t = unserialize($cache->data);
}
if (is_array($locale_t) && array_key_exists($string, $locale_t)) {
$string = $locale_t[$string];
}
else {
$result = db_query("SELECT lid, $locale FROM {locales} WHERE string = '%s'", $string);
if (!db_fetch_object($result)) {
db_query("INSERT INTO {locales} (string, location) VALUES ('%s', '%s')", $string, request_uri());
cache_clear_all("locale:$locale");
}
}
return $string;
}
?>
This diff is collapsed.
<?php
// $Id$
function page_help($section = "admin/help#page") {
$output = "";
switch ($section) {
case 'admin/help#page':
$output .= "<p>The page module is used to create a <i>static page</i>. Unlike a story, a static page is a persistent web page on your site which usually shortcuts the typical lifecycle of user generated content (i.e. submit -&gt; moderate -&gt; post -&gt; comment). A static page is usually linked from the main navigation bar, using whatever text the author wishes. To create a static page without this navigation link, simply skip the link text field.</p>";
$output .= "<p>Site pages, unlike many other forms of Drupal content, may be made of PHP code in addition to HTML and text. All Drupal objects and functions are available to a site administrator.</p>";
$output = t($output);
break;
case 'admin/system/modules#description':
$output = t("Enables the creation of a static pages that can be added to the navigation system.");
break;
}
return $output;
}
function page_perm() {
return array("maintain static pages");
}
function page_node($field) {
$info["name"] = t("static page");
$info["description"] = t("If you just want to add a page with a link in the menu to your site, this would be the best choice. Unlike a story, a static page by-passes the submission queue.");
return $info[$field];
}
function page_access($op, $node) {
if ($op == "view") {
return $node->status;
}
if ($op == "create") {
return user_access("maintain static pages");
}
if ($op == "update") {
return user_access("maintain static pages");
}
if ($op == "delete") {
return user_access("maintain static pages");
}
}
function page_save($op, $node) {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "decline") {
return array("status" => 0);
}
}
function page_insert($node) {
db_query("INSERT INTO {page} (nid, format, link, description) VALUES (%d, %d, '%s', '%s')", $node->nid, $node->format, $node->link, $node->description);
}
function page_update($node) {
db_query("UPDATE {page} SET format = %d, link = '%s', description = '%s' WHERE nid = %d", $node->format, $node->link, $node->description, $node->nid);
}
function page_delete(&$node) {
db_query("DELETE FROM {page} WHERE nid = %d", $node->nid);
}
function page_load($node) {
$page = db_fetch_object(db_query("SELECT format, link, description FROM {page} WHERE nid = %d", $node->nid));
return $page;
}
function page_link($type) {
$links = array();
if ($type == "page" && user_access("access content")) {
$result = db_query("SELECT n.nid, n.title, p.link, p.description FROM {page} p INNER JOIN {node} n ON p.nid = n.nid WHERE n.status = '1' AND p.link != '' ORDER BY p.link");
while ($page = db_fetch_object($result)) {
$links[] = l($page->link, "node/view/$page->nid", array("title" => $page->description));
}
}
if ($type == "system") {
if (user_access("maintain static pages")) {
menu("node/add/page", t("static page"), "page_page", 0);
}
}
return $links;
}
function page_content($node) {
/*
** Extract the page body. If body is dynamic (using PHP code), the body
** will be generated.
*/
if ($node->format == 0) {
// HTML type
$node->teaser = check_output($node->teaser);
$node->body = check_output($node->body);
}
else {
// PHP type
ob_start();
eval($node->body);
$node->teaser = $node->body = ob_get_contents();
ob_end_clean();
}
return $node;
}
function page_view($node, $main) {
// prepair the node content
$node = page_content($node);
// print the node
theme("node", $node, $main);
}
function page_form(&$node, &$help, &$error) {
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("page", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 20);
$output .= form_textfield(t("Link name"), "link", $node->link, 60, 64, t("To make the page show up in the navigation links, enter the name of the link, otherwise leave blank."));
$output .= form_textfield(t("Link description"), "description", $node->description, 60, 64, t("The description displayed when hovering over the page's link. Leave blank when you don't want a description."));
$output .= form_select(t("Type"), "format", $node->format, array(0 => "HTML", 1 => "PHP"));
return $output;
}
function page_validate(&$node) {
if ($node->format && user_access("create php content")) {
// Do not filter PHP code, do not auto-extract a teaser
$node->teaser = $node->body;
}
else {
$node->format = 0;
}
}
?>
This diff is collapsed.
This diff is collapsed.
......@@ -328,7 +328,7 @@ function poll_view_results(&$node, $main, $block, $links) {
}
$output .= "<div class=\"total\">". t("Total votes") .": $votestotal</div>";
$output .= ($block ? "<div class=\"links\" />". theme("links", $links) ."</div>" : "") ."</div>";
$output .= ($block ? "<div class=\"links\">". theme("links", $links) ."</div>" : "") ."</div>";
return $output;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment