From ce9a4162bc45211021c3e5e946ff017f190ab429 Mon Sep 17 00:00:00 2001 From: mikelittle Date: Wed, 30 Jul 2003 14:44:57 +0000 Subject: [PATCH] Added admin configuration of link categories, added functons to use that. Updated install and upgrade scripts Added recently updated pre/append text git-svn-id: http://svn.automattic.com/wordpress/trunk@280 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/help/en/linkcategories.php.help.html | 78 +++++ wp-admin/help/en/linkcategories.php.htlp.html | 52 --- wp-admin/linkcategories.php | 322 +++++++++++++++--- wp-admin/linkmanager.php | 52 ++- wp-admin/upgrade-071-to-072.php | 116 ++++++- wp-admin/wp-install-helper.php | 8 +- wp-admin/wp-install.php | 10 + 7 files changed, 509 insertions(+), 129 deletions(-) create mode 100644 wp-admin/help/en/linkcategories.php.help.html delete mode 100644 wp-admin/help/en/linkcategories.php.htlp.html diff --git a/wp-admin/help/en/linkcategories.php.help.html b/wp-admin/help/en/linkcategories.php.help.html new file mode 100644 index 0000000000..c292c89379 --- /dev/null +++ b/wp-admin/help/en/linkcategories.php.help.html @@ -0,0 +1,78 @@ + + + + WordPress — Docs + + + + + + + + + +
+ +

WordPress

+ +

Reference

+
+ + + +
This list display all the link categories you have defined with their + settings. When used in conjunction with the 'Delete' or 'Edit' button it + allows you to delete or edit the selected category. When editing, you can set + all the same settings as when adding a new + category.
+ + + +

Here you can create a new link category. The following settings can be + defined for your link category:

+
    +
  • Name: The name of the link category.
  • +
  • Auto-toggle: Check this if you want your category to + use the auto-toggle feature.
  • +
  • Show Images: Check this to show the images for links + in this category.
  • +
  • Show Description: Check this to show the description + for links in this category.
  • +
  • Show Rating: Check this to show the rating for links + in this category.
  • +
  • Show Updated: Check this to show (as a tooltip) the + updated timestamp for links in this category.
  • +
  • Sort Order: The order in which the links in this + category should be displayed.
  • +
  • Descending: Checking this will reverese the sort + order selected (usually used for when sorted by updated or rating).
  • +
  • Text/HTML before: The text or HTML to be output + before each link.
  • +
  • Text/HTML between: The text or HTML to be output + before after each link or image but before the description or rating.
  • +
  • Text/HTML after: The text or HTML to be output after + each link and its's description and/or rating.
  • +
  • Limit: Enter a number here to limit the number of + links displayed from this category.
  • +
+

Click on the 'Add Category!' button to add your new category.

+ +
Auto-toggle
+ +
Auto toggle is a setting for a link category. Setting this to on means + that whenever you edit links in this category, the system will only allow one + link at a time to be visible. If you set a link to be visible, or create a new + link with a visible state, the system will automatically turn off the + visibility of all the other links in that category. Some suggestions for this + functionality include a set of 'Mood' links, only one of which is 'active' at + any time; or a collection of links to CD's and set the one to which you are + currently listening to visible. All the other links will automatically be made + invisible.
+ +
+
+
+ + \ No newline at end of file diff --git a/wp-admin/help/en/linkcategories.php.htlp.html b/wp-admin/help/en/linkcategories.php.htlp.html deleted file mode 100644 index 498db825aa..0000000000 --- a/wp-admin/help/en/linkcategories.php.htlp.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - WordPress — Docs - - - - - - - - - -
- -

WordPress

- -

Reference

-
- - -
This drop down list contains all the link categories you have defined. - When used in conjunction with the 'Delete' or 'Edit' button it allows you to - delete or edit (rename) the selected category.
- - - - -
Here you can create a new link category. There is an input box for the - name of the category. There is a checkbox for the auto-toggle state of the new - link. Type in the name, click the check box if you want this category to be - auto-toggle, then click on the 'Add it!' button.
- -
Auto-toggle
- -
Auto toggle is a setting for a link category. Setting this to on means - that whenever you edit links in this category, the system will only allow one - link at a time to be visible. If you set a link to be visible, or create a new - link with a visible state, the system will automatically turn off the - visibility of all the other links in that category. Some suggestions for this - functionality include a set of 'Mood' links, only one of which is 'active' at - any time; or a collection of links to CD's and set the one to which you are - currently listening to visible. All the other links will automatically be made - invisible.
- -
-
-
- - \ No newline at end of file diff --git a/wp-admin/linkcategories.php b/wp-admin/linkcategories.php index 1208b7d0b1..e20240d814 100644 --- a/wp-admin/linkcategories.php +++ b/wp-admin/linkcategories.php @@ -56,15 +56,53 @@ switch ($action) { if ($user_level < $minadminlevel) die ("Cheatin' uh ?"); - + $cat_name=addslashes($HTTP_POST_VARS["cat_name"]); $auto_toggle = $HTTP_POST_VARS["auto_toggle"]; if ($auto_toggle != 'Y') { $auto_toggle = 'N'; } - $wpdb->query("INSERT INTO $tablelinkcategories (cat_id,cat_name, auto_toggle) VALUES ('0', '$cat_name', '$auto_toggle')"); + $show_images = $HTTP_POST_VARS["show_images"]; + if ($show_images != 'Y') { + $show_images = 'N'; + } + $show_description = $HTTP_POST_VARS["show_description"]; + if ($show_description != 'Y') { + $show_description = 'N'; + } + + $show_rating = $HTTP_POST_VARS["show_rating"]; + if ($show_rating != 'Y') { + $show_rating = 'N'; + } + + $show_updated = $HTTP_POST_VARS["show_updated"]; + if ($show_updated != 'Y') { + $show_updated = 'N'; + } + + $sort_order = $HTTP_POST_VARS["sort_order"]; + + $sort_desc = $HTTP_POST_VARS["sort_desc"]; + if ($sort_desc != 'Y') { + $sort_desc = 'N'; + } + $text_before_link = addslashes($HTTP_POST_VARS["text_before_link"]); + $text_after_link = addslashes($HTTP_POST_VARS["text_after_link"]); + $text_after_all = addslashes($HTTP_POST_VARS["text_after_all"]); + + $list_limit = $HTTP_POST_VARS["list_limit"]; + if ($list_limit == '') + $list_limit = -1; + + $wpdb->query("INSERT INTO $tablelinkcategories (cat_id, cat_name, auto_toggle, show_images, show_description, \n" . + " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit) \n" . + " VALUES ('0', '$cat_name', '$auto_toggle', '$show_images', '$show_description', \n" . + " '$show_rating', '$show_updated', '$sort_order', '$sort_desc', '$text_before_link', '$text_after_link', \n" . + " '$text_after_all', $list_limit)"); + header("Location: linkcategories.php"); break; } // end addcat @@ -82,7 +120,7 @@ switch ($action) { if ($user_level < $minadminlevel) die ("Cheatin' uh ?"); - + $wpdb->query("DELETE FROM $tablelinkcategories WHERE cat_id='$cat_id'"); $wpdb->query("UPDATE $tablelinks SET link_category=1 WHERE link_category='$cat_id'"); @@ -93,24 +131,81 @@ switch ($action) { { include_once ("./b2header.php"); $cat_id = $HTTP_POST_VARS["cat_id"]; - $cat_name=get_linkcatname($cat_id); - $cat_name=addslashes($cat_name); - $auto_toggle=get_autotoggle($cat_id); + $row = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, " + . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, " + . " text_after_all, list_limit FROM $tablelinkcategories WHERE cat_id=$cat_id"); + if ($row) { + if ($row->list_limit == -1) { + $row->list_limit = ''; + } ?>
-

Old name:

+

Edit Link Category 'cat_name?>'

- New name:
- " /> -
- /> auto-toggle?
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name:    + auto_toggle == 'Y') ? 'checked' : '';?> value="Y" /> auto-toggle?
Show: + show_images == 'Y') ? 'checked' : '';?> value="Y" /> images   + show_description == 'Y') ? 'checked' : '';?> value="Y" /> description   + show_rating == 'Y') ? 'checked' : '';?> value="Y" /> rating   + show_updated == 'Y') ? 'checked' : '';?> value="Y" /> updated +
Sort order: +    + sort_desc == 'Y') ? 'checked' : '';?> value="Y" /> Descending?
+
Text/HTML 
before:
between:
after:
limit: (leave empty for no limit)
+   + +

query("UPDATE $tablelinkcategories SET cat_name='$cat_name', auto_toggle='$auto_toggle' WHERE cat_id=$cat_id"); + $show_images = $HTTP_POST_VARS["show_images"]; + if ($show_images != 'Y') { + $show_images = 'N'; + } + + $show_description = $HTTP_POST_VARS["show_description"]; + if ($show_description != 'Y') { + $show_description = 'N'; + } + + $show_rating = $HTTP_POST_VARS["show_rating"]; + if ($show_rating != 'Y') { + $show_rating = 'N'; + } + + $show_updated = $HTTP_POST_VARS["show_updated"]; + if ($show_updated != 'Y') { + $show_updated = 'N'; + } + + $sort_order = $HTTP_POST_VARS["sort_order"]; + + $sort_desc = $HTTP_POST_VARS["sort_desc"]; + if ($sort_desc != 'Y') { + $sort_desc = 'N'; + } + $text_before_link = addslashes($HTTP_POST_VARS["text_before_link"]); + $text_after_link = addslashes($HTTP_POST_VARS["text_after_link"]); + $text_after_all = addslashes($HTTP_POST_VARS["text_after_all"]); + + $list_limit = $HTTP_POST_VARS["list_limit"]; + if ($list_limit == '') + $list_limit = -1; + + $wpdb->query("UPDATE $tablelinkcategories set + cat_name='$cat_name', + auto_toggle='$auto_toggle', + show_images='$show_images', + show_description='$show_description', + show_rating='$show_rating', + show_updated='$show_updated', + sort_order='$sort_order', + sort_desc='$sort_desc', + text_before_link='$text_before_link', + text_after_link='$text_after_link', + text_after_all='$text_after_all', + list_limit=$list_limit + WHERE cat_id=$cat_id + "); + } // end if save + header("Location: linkcategories.php"); break; - } // end edit + } // end editcat default: { $standalone=0; @@ -140,42 +291,127 @@ switch ($action) { ?>
-
Link Categories:
Edit a link category:
+ + + + + + + + + + + + + + + + + + + + + + + + get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id"); - echo " \n"; + if ($row->list_limit == -1) { + $row->list_limit = 'none'; + } + $style = ($i % 2) ? ' class="alternate"' : ''; ?> -

- - + > + + + + + + + + + + + + + + + + + +
IdNameAuto
Toggle?
ShowSort OrderDesc?Text/HTMLLimit 
images?desc?rating?updated?beforebetweenafter
cat_id?>cat_name)?>auto_toggle?>show_images?>show_description?>show_rating?>show_updated?>sort_order?>sort_desc?>text_before_link)?> text_after_link)?> text_after_all)?>list_limit?>
+ +
- - - - - - Add a link category:
-
- -   auto-toggle?

- -
- +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Add a Link Category:
Name:    + auto-toggle?
Show: + images   + description   + rating   + updated
Sort order:   + Descending?
Text/HTML 
before:
between:
after:
limit: (leave empty for no limit)
diff --git a/wp-admin/linkmanager.php b/wp-admin/linkmanager.php index df627bbf24..390798dc6c 100644 --- a/wp-admin/linkmanager.php +++ b/wp-admin/linkmanager.php @@ -31,10 +31,11 @@ require_once('../wp-links/links.config.php'); require_once("../wp-links/links.php"); $title = 'Manage Links'; +$this_file = 'linkmanager.php'; function category_dropdown($fieldname, $selected = 0) { global $wpdb, $tablelinkcategories; - + $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id"); echo ' + value="Y"> Yes   @@ -465,7 +464,7 @@ switch ($action) { if ($action != "popup") { ?> +
@@ -563,10 +562,7 @@ function checkAll(form) LEFT JOIN $tablelinkcategories ON $tablelinks.link_category = $tablelinkcategories.cat_id LEFT JOIN $tableusers ON $tableusers.ID = $tablelinks.link_owner "; - //$use_adminlevels = 0; - if (isset($cat_id) && ($cat_id != 'All')) { - // have we already started the where clause? $sql .= " WHERE link_category = $cat_id "; } $sql .= ' ORDER BY link_' . $sqlorderby; @@ -601,11 +597,11 @@ function checkAll(form) $visible LINKS; $show_buttons = 1; // default - + if ($use_adminlevels && ($link->user_level > $user_level)) { $show_buttons = 0; } - + if ($show_buttons) { echo << @@ -736,7 +732,7 @@ LINKS;
-

You can drag link this to your toolbar and when you click it a window will pop up that will allow you to add whatever site you're on to your links! Right now this only works on Mozilla or Netscape, but we're working on it.

+

You can drag link this to your toolbar and when you click it a window will pop up that will allow you to add whatever site you're on to your links! Right now this only works on Mozilla or Netscape, but we're working on it.

'; } else { $res .= 'There was a problem with ' . $tablename . '
'; ++$error_count; } + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN show_images enum('Y','N') NOT NULL default 'Y'"; +maybe_add_column($tablename, 'show_images', $ddl); +if (check_column($tablename, 'show_images', "enum('Y','N')")) { + $res .= $tablename . ' - ok
'; +} else { + $res .= 'There was a problem with ' . $tablename . '
'; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN show_description enum('Y','N') NOT NULL default 'Y'"; +maybe_add_column($tablename, 'show_description', $ddl); +if (check_column($tablename, 'show_description', "enum('Y','N')")) { + $res .= $tablename . ' - ok
'; +} else { + $res .= 'There was a problem with ' . $tablename . '
'; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN show_rating enum('Y','N') NOT NULL default 'Y'"; +maybe_add_column($tablename, 'show_rating', $ddl); +if (check_column($tablename, 'show_rating', "enum('Y','N')")) { + $res .= $tablename . ' - ok
'; +} else { + $res .= 'There was a problem with ' . $tablename . '
'; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN show_updated enum('Y','N') NOT NULL default 'Y'"; +maybe_add_column($tablename, 'show_updated', $ddl); +if (check_column($tablename, 'show_updated', "enum('Y','N')")) { + $res .= $tablename . ' - ok
'; +} else { + $res .= 'There was a problem with ' . $tablename . '
'; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN sort_order varchar(64) NOT NULL default 'name'"; +maybe_add_column($tablename, 'sort_order', $ddl); +if (check_column($tablename, 'sort_order', "varchar(64)")) { + $res .= $tablename . ' - ok
'; +} else { + $res .= 'There was a problem with ' . $tablename . '
'; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN sort_desc enum('Y','N') NOT NULL default 'N'"; +maybe_add_column($tablename, 'sort_desc', $ddl); +if (check_column($tablename, 'sort_Desc', "enum('Y','N')")) { + $res .= $tablename . ' - ok
'; +} else { + $res .= 'There was a problem with ' . $tablename . '
'; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN text_before_link varchar(128) not null default '
  • '"; +maybe_add_column($tablename, 'text_before_link', $ddl); +if (check_column($tablename, 'text_before_link', 'varchar(128)')) { + $res .= $tablename . ' - ok
    '; +} else { + $res .= 'There was a problem with ' . $tablename . '
    '; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN text_after_link varchar(128) not null default '
    '"; +maybe_add_column($tablename, 'text_after_link', $ddl); +if (check_column($tablename, 'text_after_link', 'varchar(128)')) { + $res .= $tablename . ' - ok
    '; +} else { + $res .= 'There was a problem with ' . $tablename . '
    '; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN text_after_all varchar(128) not null default '
  • '"; +maybe_add_column($tablename, 'text_after_all', $ddl); +if (check_column($tablename, 'text_after_all', 'varchar(128)')) { + $res .= $tablename . ' - ok
    '; +} else { + $res .= 'There was a problem with ' . $tablename . '
    '; + ++$error_count; +} + +$tablename = $tablelinkcategories; +$ddl = "ALTER TABLE $tablelinkcategories ADD COLUMN list_limit int not null default -1"; +maybe_add_column($tablename, 'list_limit', $ddl); +if (check_column($tablename, 'list_limit', 'int(11)')) { + $res .= $tablename . ' - ok
    '; +} else { + $res .= 'There was a problem with ' . $tablename . '
    '; + ++$error_count; +} + +if ($error_count > 0) { +?> +

    Hmmm... there was some kind of error. If you cannot figure out + see from the output above how to correct the problems please + visit our support + forums and report your problem.

    +

    OK, that wasn't too bad was it? Let's move on to step 2!

    -

    Step 2

    @@ -104,7 +214,7 @@ CREATE TABLE $tableoptions ( option_id int(11) NOT NULL auto_increment, blog_id int(11) NOT NULL default 0, option_name varchar(64) NOT NULL default '', - option_can_override enum ('Y','N') NOT NULL default 'Y', + option_can_override enum('Y','N') NOT NULL default 'Y', option_type int(11) NOT NULL default 1, option_value varchar(255) NOT NULL default '', option_width int NOT NULL default 20, diff --git a/wp-admin/wp-install-helper.php b/wp-admin/wp-install-helper.php index 8a3ab8d811..08161c4154 100644 --- a/wp-admin/wp-install-helper.php +++ b/wp-admin/wp-install-helper.php @@ -95,10 +95,10 @@ function check_column($table_name, $col_name, $col_type, $is_null = null, $key = $results = $wpdb->get_results("DESC $table_name"); foreach ($results as $row ) { - print_r($row); + //print_r($row); if ($row->Field == $col_name) { // got our column, check the params - echo ("checking $row->Type != $col_type\n"); + //echo ("checking $row->Type against $col_type\n"); if (($col_type != null) && ($row->Type != $col_type)) { ++$diffs; } @@ -114,8 +114,10 @@ function check_column($table_name, $col_name, $col_type, $is_null = null, $key = if (($extra != null) && ($row->Extra != $extra)) { ++$diffs; } - if ($diffs > 0) + if ($diffs > 0) { + //echo ("diffs = $diffs returning false\n"); return false; + } return true; } // end if found our column } diff --git a/wp-admin/wp-install.php b/wp-admin/wp-install.php index 41826e09b0..2bed723a50 100644 --- a/wp-admin/wp-install.php +++ b/wp-admin/wp-install.php @@ -89,6 +89,16 @@ if (!$got_cats) { " cat_id int(11) NOT NULL auto_increment, " . " cat_name tinytext NOT NULL, ". " auto_toggle enum ('Y','N') NOT NULL default 'N', ". + " show_images enum ('Y','N') NOT NULL default 'Y', " . + " show_description enum ('Y','N') NOT NULL default 'Y', " . + " show_rating enum ('Y','N') NOT NULL default 'Y', " . + " show_updated enum ('Y','N') NOT NULL default 'Y', " . + " sort_order varchar(64) NOT NULL default 'name', " . + " sort_desc enum('Y','N') NOT NULL default 'N', " . + " text_before_link varchar(128) not null default '
  • ', " . + " text_after_link varchar(128) not null default '
    '," . + " text_after_all varchar(128) not null default '
  • ', " . + " list_limit int not null default -1, " . " PRIMARY KEY (cat_id) ". ") "; $result = mysql_query($sql) or print ("Can't create the table '$tablelinkcategories' in the database.
    " . $sql . "
    " . mysql_error());