Skip to content

Commit

Permalink
- changed block, module and theme config pages to use checkboxes.
Browse files Browse the repository at this point in the history
- coding style clean ups.
- fixed taxonomy causing errors.
  • Loading branch information
Kjartan Mannes committed May 11, 2002
1 parent c72bf4b commit 86552cb
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 46 deletions.
12 changes: 6 additions & 6 deletions includes/common.inc
Expand Up @@ -96,7 +96,7 @@ function request_uri() {
return $REQUEST_URI;
}
else {
return $PATH_INFO . "?" . $QUERY_STRING;
return $PATH_INFO ."?". $QUERY_STRING;
}
}

Expand Down Expand Up @@ -420,7 +420,7 @@ function format_rss_channel($title, $link, $description, $items, $language = "en
$output .= " <description>". htmlentities($description) ."</description>\n";
$output .= " <language>". htmlentities(strip_tags($language)) ."</language>\n";
foreach ($args as $key => $value) {
$output .= "<$key>" . htmlentities(strip_tags($value)) . "</$key>";
$output .= "<$key>". htmlentities(strip_tags($value)) ."</$key>";
}
$output .= $items;
$output .= "</channel>\n";
Expand All @@ -436,7 +436,7 @@ function format_rss_item($title, $link, $description, $args = array()) {
$output .= " <link>". htmlentities(strip_tags($link)) ."</link>\n";
$output .= " <description>". htmlentities($description) ."</description>\n";
foreach ($args as $key => $value) {
$output .= "<$key>" . htmlentities(strip_tags($value)) . "</$key>";
$output .= "<$key>". htmlentities(strip_tags($value)) ."</$key>";
}
$output .= "</item>\n";

Expand Down Expand Up @@ -509,7 +509,7 @@ function page_get_cache() {

function format_interval($timestamp) {
$units = array("year|years" => 31536000, "week|weeks" => 604800, "day|days" => 86400, "hour|hours" => 3600, "min|min" => 60, "sec|sec" => 1);
foreach ($units as $key=>$value) {
foreach ($units as $key => $value) {
$key = explode("|", $key);
if ($timestamp >= $value) {
$output .= ($output ? " " : "") . format_plural(floor($timestamp / $value), $key[0], $key[1]);
Expand Down Expand Up @@ -543,7 +543,7 @@ function format_date($timestamp, $type = "medium", $format = "") {
$date = date($c, $timestamp).$date;
}
else {
$date = $c.$date;
$date = $c . $date;
}
}
break;
Expand Down Expand Up @@ -610,7 +610,7 @@ function form_textarea($title, $name, $value, $cols, $rows, $description = 0) {

function form_select($title, $name, $value, $options, $description = 0, $extra = 0, $multiple = 0) {
if (count($options) > 0) {
foreach ($options as $key=>$choice) {
foreach ($options as $key => $choice) {
$select .= "<option value=\"$key\"". (is_array($value) ? (in_array($key, $value) ? " selected=\"selected\"" : "") : ($key == $value ? " selected=\"selected\"" : "")) .">". check_form($choice) ."</option>";
}
return form_item($title, "<select name=\"edit[$name]". ($multiple ? "[]" : "") ."\"". ($multiple ? " multiple " : "") . ($extra ? " $extra" : "") .">$select</select>", $description);
Expand Down
5 changes: 2 additions & 3 deletions modules/archive.module
Expand Up @@ -146,9 +146,8 @@ function archive_page() {
$edit["day"] = date("d", $date);
}

$start = str_replace("<b>:</b><br />", " ", form_select("", "year", ($edit["year"] ? $edit["year"] : date("Y")), $years) . form_select("", "month", ($edit["month"] ? $edit["month"] : date("m")), $months) . form_select("", "day", ($edit["day"] ? $edit["day"] : date("d")), $days) . form_submit(t("Show")));
$start = str_replace("<p>", "", $start);
$start = str_replace("</p>\n", " ", $start);
$start = form_select("", "year", ($edit["year"] ? $edit["year"] : date("Y")), $years) . form_select("", "month", ($edit["month"] ? $edit["month"] : date("m")), $months) . form_select("", "day", ($edit["day"] ? $edit["day"] : date("d")), $days) . form_submit(t("Show"));
$start = ereg_replace("<[/]?p>", "", $start);

$theme->box(t("Archives"), form($start));

Expand Down
5 changes: 2 additions & 3 deletions modules/archive/archive.module
Expand Up @@ -146,9 +146,8 @@ function archive_page() {
$edit["day"] = date("d", $date);
}

$start = str_replace("<b>:</b><br />", " ", form_select("", "year", ($edit["year"] ? $edit["year"] : date("Y")), $years) . form_select("", "month", ($edit["month"] ? $edit["month"] : date("m")), $months) . form_select("", "day", ($edit["day"] ? $edit["day"] : date("d")), $days) . form_submit(t("Show")));
$start = str_replace("<p>", "", $start);
$start = str_replace("</p>\n", " ", $start);
$start = form_select("", "year", ($edit["year"] ? $edit["year"] : date("Y")), $years) . form_select("", "month", ($edit["month"] ? $edit["month"] : date("m")), $months) . form_select("", "day", ($edit["day"] ? $edit["day"] : date("d")), $days) . form_submit(t("Show"));
$start = ereg_replace("<[/]?p>", "", $start);

$theme->box(t("Archives"), form($start));

Expand Down
8 changes: 4 additions & 4 deletions modules/block.module
Expand Up @@ -61,7 +61,7 @@ function block_block() {
}

function block_admin_save($edit) {
foreach ($edit as $key=>$value) {
foreach ($edit as $key => $value) {
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE name = '%s'", $value["region"], $value["status"], $value["custom"], $value["path"], $value["weight"], $key);
}
}
Expand All @@ -71,7 +71,7 @@ function block_admin_display() {

// Generate output:
$output = "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= "<tr><th>block</th><th>module</th><th>status</th><th>custom</th><th>weight</th><th>region</th><th>path</th><th colspan=\"2\">operations</th></tr>\n";
$output .= "<tr><th>block</th><th>module</th><th>enabled</th><th>custom</th><th>weight</th><th>region</th><th>path</th><th colspan=\"2\">operations</th></tr>\n";

while ($block = db_fetch_object($result)) {
$weights = array(0 => 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
Expand All @@ -80,8 +80,8 @@ function block_admin_display() {
//$output .= '<td>'. la($block->name, array("mod" => "block", "op" => "view", "id" => $block->delta), t("View the block details")) .'</td>';
$output .= "<td>$block->name</td>";
$output .= '<td>'. (module_hook($block->module, "admin") ? la($block->module, array("mod" => $block->module), "Administer module") : $block->module) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][status", $block->status, array("disabled", "enabled")) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][custom", $block->custom, array("disabled", "enabled")) .'</td>';
$output .= '<td align="center">'. form_checkbox(NULL, "$block->name][status", 1, $block->status) .'</td>';
$output .= '<td align="center">'. form_checkbox(NULL, "$block->name][custom", 1, $block->custom) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][weight", $block->weight, $weights) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][region", $block->region, array("left", "right")) .'</td>';
$output .= '<td>'. form_textfield(NULL, "$block->name][path", $block->path, 10, 255) .'</td>';
Expand Down
8 changes: 4 additions & 4 deletions modules/block/block.module
Expand Up @@ -61,7 +61,7 @@ function block_block() {
}

function block_admin_save($edit) {
foreach ($edit as $key=>$value) {
foreach ($edit as $key => $value) {
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE name = '%s'", $value["region"], $value["status"], $value["custom"], $value["path"], $value["weight"], $key);
}
}
Expand All @@ -71,7 +71,7 @@ function block_admin_display() {

// Generate output:
$output = "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= "<tr><th>block</th><th>module</th><th>status</th><th>custom</th><th>weight</th><th>region</th><th>path</th><th colspan=\"2\">operations</th></tr>\n";
$output .= "<tr><th>block</th><th>module</th><th>enabled</th><th>custom</th><th>weight</th><th>region</th><th>path</th><th colspan=\"2\">operations</th></tr>\n";

while ($block = db_fetch_object($result)) {
$weights = array(0 => 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
Expand All @@ -80,8 +80,8 @@ function block_admin_display() {
//$output .= '<td>'. la($block->name, array("mod" => "block", "op" => "view", "id" => $block->delta), t("View the block details")) .'</td>';
$output .= "<td>$block->name</td>";
$output .= '<td>'. (module_hook($block->module, "admin") ? la($block->module, array("mod" => $block->module), "Administer module") : $block->module) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][status", $block->status, array("disabled", "enabled")) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][custom", $block->custom, array("disabled", "enabled")) .'</td>';
$output .= '<td align="center">'. form_checkbox(NULL, "$block->name][status", 1, $block->status) .'</td>';
$output .= '<td align="center">'. form_checkbox(NULL, "$block->name][custom", 1, $block->custom) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][weight", $block->weight, $weights) .'</td>';
$output .= '<td>'. form_select(NULL, "$block->name][region", $block->region, array("left", "right")) .'</td>';
$output .= '<td>'. form_textfield(NULL, "$block->name][path", $block->path, 10, 255) .'</td>';
Expand Down
16 changes: 11 additions & 5 deletions modules/node.module
Expand Up @@ -416,7 +416,7 @@ function node_admin_settings($edit = array()) {
** Reset the configuration options to their default value:
*/

foreach ($edit as $name=>$value) {
foreach ($edit as $name => $value) {
variable_del($name);
}
}
Expand Down Expand Up @@ -460,7 +460,7 @@ function node_admin_edit($node) {
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
$output .= " <tr><th>older revisions</th><th colspan=\"3\">operations</th></tr>";
foreach ($node->revisions as $key => $revision) {
$output .= " <tr><td>". t("revision #%r revised by %u on %d", array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "<br /><small>". $revision["history"] ."</small>" : "") ."</td><td>". l(t("view revision"), array("id" => $node->nid, "revision" =>$key)) ."</td><td>". la(t("rollback revision"), array("mod" => "node", "op" => "rollback+revision", "id" => $node->nid, "revision" => $key)) ."</td><td>". la(t("delete revision"), array("mod" => "node", "op" => "delete+revision", "id" => $node->nid, "revision" => $key)) ."</td></tr>";
$output .= " <tr><td>". t("revision #%r revised by %u on %d", array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "<br /><small>". $revision["history"] ."</small>" : "") ."</td><td>". l(t("view revision"), array("id" => $node->nid, "revision" => $key)) ."</td><td>". la(t("rollback revision"), array("mod" => "node", "op" => "rollback+revision", "id" => $node->nid, "revision" => $key)) ."</td><td>". la(t("delete revision"), array("mod" => "node", "op" => "delete+revision", "id" => $node->nid, "revision" => $key)) ."</td></tr>";
}
$output .= "</table>";
}
Expand Down Expand Up @@ -1031,7 +1031,9 @@ function node_submit($node) {
** Update terms of the node
*/

taxonomy_node_save($nid, $node->taxonomy);
if (function_exists("taxonomy_node_save")) {
taxonomy_node_save($nid, $node->taxonomy);
}

watchdog("special", "$node->type: updated '$node->title'");
$output = t("The node has been updated.");
Expand Down Expand Up @@ -1076,7 +1078,9 @@ function node_submit($node) {
** Insert terms of the node
*/

taxonomy_node_save($nid, $node->taxonomy);
if (function_exists("taxonomy_node_save")) {
taxonomy_node_save($nid, $node->taxonomy);
}

watchdog("special", "$node->type: added '$node->title'");
$output = t("Thanks for your submission.");
Expand Down Expand Up @@ -1138,7 +1142,9 @@ function node_delete($edit) {
** Delete any taxonomy terms
*/

taxonomy_node_delete($node->nid);
if (function_exists("taxonomy_node_delete")) {
taxonomy_node_delete($nid, $node->taxonomy);
}

/*
** Call the node specific callback (if any):
Expand Down
16 changes: 11 additions & 5 deletions modules/node/node.module
Expand Up @@ -416,7 +416,7 @@ function node_admin_settings($edit = array()) {
** Reset the configuration options to their default value:
*/

foreach ($edit as $name=>$value) {
foreach ($edit as $name => $value) {
variable_del($name);
}
}
Expand Down Expand Up @@ -460,7 +460,7 @@ function node_admin_edit($node) {
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">";
$output .= " <tr><th>older revisions</th><th colspan=\"3\">operations</th></tr>";
foreach ($node->revisions as $key => $revision) {
$output .= " <tr><td>". t("revision #%r revised by %u on %d", array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "<br /><small>". $revision["history"] ."</small>" : "") ."</td><td>". l(t("view revision"), array("id" => $node->nid, "revision" =>$key)) ."</td><td>". la(t("rollback revision"), array("mod" => "node", "op" => "rollback+revision", "id" => $node->nid, "revision" => $key)) ."</td><td>". la(t("delete revision"), array("mod" => "node", "op" => "delete+revision", "id" => $node->nid, "revision" => $key)) ."</td></tr>";
$output .= " <tr><td>". t("revision #%r revised by %u on %d", array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "<br /><small>". $revision["history"] ."</small>" : "") ."</td><td>". l(t("view revision"), array("id" => $node->nid, "revision" => $key)) ."</td><td>". la(t("rollback revision"), array("mod" => "node", "op" => "rollback+revision", "id" => $node->nid, "revision" => $key)) ."</td><td>". la(t("delete revision"), array("mod" => "node", "op" => "delete+revision", "id" => $node->nid, "revision" => $key)) ."</td></tr>";
}
$output .= "</table>";
}
Expand Down Expand Up @@ -1031,7 +1031,9 @@ function node_submit($node) {
** Update terms of the node
*/

taxonomy_node_save($nid, $node->taxonomy);
if (function_exists("taxonomy_node_save")) {
taxonomy_node_save($nid, $node->taxonomy);
}

watchdog("special", "$node->type: updated '$node->title'");
$output = t("The node has been updated.");
Expand Down Expand Up @@ -1076,7 +1078,9 @@ function node_submit($node) {
** Insert terms of the node
*/

taxonomy_node_save($nid, $node->taxonomy);
if (function_exists("taxonomy_node_save")) {
taxonomy_node_save($nid, $node->taxonomy);
}

watchdog("special", "$node->type: added '$node->title'");
$output = t("Thanks for your submission.");
Expand Down Expand Up @@ -1138,7 +1142,9 @@ function node_delete($edit) {
** Delete any taxonomy terms
*/

taxonomy_node_delete($node->nid);
if (function_exists("taxonomy_node_delete")) {
taxonomy_node_delete($nid, $node->taxonomy);
}

/*
** Call the node specific callback (if any):
Expand Down
26 changes: 19 additions & 7 deletions modules/system.module
Expand Up @@ -78,7 +78,7 @@ function system_view_options() {

// layout settings:
$output .= "<h3>Layout settings</h3>\n";
foreach (theme_list() as $key=>$value) $options .= "<option value=\"$key\"". (variable_get("theme_default", 0) == $key ? " selected=\"selected\"" : "") .">$key</option>\n";
foreach (theme_list() as $key => $value) $options .= "<option value=\"$key\"". (variable_get("theme_default", 0) == $key ? " selected=\"selected\"" : "") .">$key</option>\n";
$output .= form_item("Default theme", "<select name=\"edit[theme_default]\">$options</select>", "The default theme as seen by visitors or anonymous users.");
$output .= "<hr />\n";

Expand Down Expand Up @@ -107,12 +107,12 @@ function system_view_filters() {
}

function system_save($edit = array()) {
foreach ($edit as $name=>$value) variable_set($name, $value);
foreach ($edit as $name => $value) variable_set($name, $value);
return "the configuration options have been saved.";
}

function system_default($edit = array()) {
foreach ($edit as $name=>$value) variable_del($name);
foreach ($edit as $name => $value) variable_del($name);
return "the configuration options have been reset to their default values.";
}

Expand Down Expand Up @@ -163,9 +163,15 @@ function system_modules() {
$required = array("user", "drupal", "system", "watchdog");

$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><th>module</th><th>description</th><th>status</th><th colspan=\"2\">operations</th></tr>\n";
$output .= "<tr><th>module</th><th>description</th><th>enabled</th><th colspan=\"2\">operations</th></tr>\n";
foreach ($modules as $name => $module) {
$output .= " <tr><td>$name</td><td>". check_output(module_invoke($name, "system", "description")) ."</td><td>". (in_array($name, $required) ? "Enabled" : form_select("", "status][$name", $module["status"], array(t("Disabled"), t("Enabled")))) ."</td><td>". (module_hook($name, "page") ? lm(t("view"), array("mod" => $name)) : "&nbsp;") ."</td><td>". (module_hook($name, "admin") ? la(t("admin"), array("mod" => $name)) : "&nbsp;") ."</td></tr>\n";
$output .= "<tr>";
$output .= "<td>$name</td>";
$output .= "<td>". check_output(module_invoke($name, "system", "description")) ."</td>";
$output .= "<td align=\"center\">". (in_array($name, $required) ? "Enabled" : form_checkbox("", "status][$name", 1, $module["status"])) ."</td>";
$output .= "<td>". (module_hook($name, "page") ? lm(t("view"), array("mod" => $name)) : "&nbsp;") ."</td>";
$output .= "<td>". (module_hook($name, "admin") ? la(t("admin"), array("mod" => $name)) : "&nbsp;") ."</td>";
$output .= "</tr>\n";
if (!in_array($name, $required)) {
db_query("INSERT INTO system SET name = '$name', type = 'module', filename = '$module[filename]', status = '$module[status]'");
}
Expand Down Expand Up @@ -229,9 +235,15 @@ function system_themes() {
db_query("DELETE FROM system WHERE type = 'theme'");

$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><th>theme</th><th>name</th><th>description</th><th>author</th><th>status</th></tr>\n";
$output .= "<tr><th>theme</th><th>name</th><th>description</th><th>author</th><th>enabled</th></tr>\n";
foreach ($themes as $name => $theme) {
$output .= " <tr><td>$name</td><td>$theme->displayname</td><td>". form_textfield("", "$name][description", $theme->description, 40, 255)."</td><td>$theme->author</td><td>". form_select("", "$name][status", $theme->status, array(t("Disabled"), t("Enabled"))) ."</td></tr>\n";
$output .= "<tr>";
$output .= "<td>$name</td>";
$output .= "<td>$theme->displayname</td>";
$output .= "<td>". form_textfield("", "$name][description", $theme->description, 40, 255)."</td>";
$output .= "<td>$theme->author</td>";
$output .= "<td align=\"center\">". form_checkbox("", "$name][status", 1, $theme->status) ."</td>";
$output .= "</tr>\n";
db_query("INSERT INTO system SET name = '$name', type = 'theme', filename = '$theme->filename', status = '$theme->status', description = '$theme->description'");
}
$output .= "</table><br />\n";
Expand Down

0 comments on commit 86552cb

Please sign in to comment.