- Various improvements to the menu system.
- Changed the import and taxonomy module to use better URLs. Patches by Al. - Fixed locale module weirdness. Patch by Kjartan.4.2.x
parent
a92bfba707
commit
3ad7449bc7
|
@ -147,7 +147,7 @@ function t($string, $args = 0) {
|
|||
** => url("user/register")));
|
||||
*/
|
||||
|
||||
$string = ($languages && function_exists("locale") ? locale($string) : $string);
|
||||
$string = ($languages && module_exist("locale") ? locale($string) : $string);
|
||||
|
||||
if (!$args) {
|
||||
return $string;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
// $Id$
|
||||
|
||||
// TODO:
|
||||
// 1. add 'access' flag.
|
||||
|
||||
function menu_add() {
|
||||
trigger_error(t("The 'menu_add()' function is deprecated."), E_USER_ERROR);
|
||||
// Note that this function will be removed shortly.
|
||||
|
@ -10,27 +13,34 @@ function menu($path, $title, $callback = NULL, $help = NULL, $weight = 0, $hidde
|
|||
global $_gmenu;
|
||||
|
||||
if (isset($_gmenu[$path])) {
|
||||
if (empty($_gmenu[$path]["callback"])) { // dummy item -> fill in
|
||||
$_gmenu[$path] = array("title" => $title, "callback" => $callback, "help" => $help, "weight" => $weight, "hidden" => $hidden, "children" => $_gmenu[$path]["children"]);
|
||||
return true;
|
||||
}
|
||||
else { // real item found
|
||||
trigger_error(t("While trying to add '%path' to menu, item already exists.", array("%path" => $path)), E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
trigger_error("trying to add '$path' which already exists");
|
||||
}
|
||||
// if this is reached we need to create a new item
|
||||
$_gmenu[$path] = array("title" => $title, "callback" => $callback, "help" => $help, "weight" => $weight, "hidden" => $hidden, "children" => array());
|
||||
// does the item have an existing parent?
|
||||
$parent = substr($path, 0, strrpos($path, "/"));
|
||||
while (!isset($_gmenu[$parent])) {
|
||||
$_gmenu[$parent] = array("children" => array($path));
|
||||
$path = $parent;
|
||||
$parent = substr($parent, 0, strrpos($parent, "/"));
|
||||
}
|
||||
$_gmenu[$parent]["children"][] = $path;
|
||||
else {
|
||||
// add the menu to the flat list of menu items:
|
||||
$_gmenu[$path] = array("title" => $title, "callback" => $callback, "help" => $help, "weight" => $weight, "hidden" => $hidden, "children" => array());
|
||||
|
||||
return true;
|
||||
// find the best matching parent item:
|
||||
$parent = substr($path, 0, strrpos($path, "/"));
|
||||
while ($parent && !$_gmenu[$parent]) {
|
||||
$parent = substr($parent, 0, strrpos($parent, "/"));
|
||||
}
|
||||
|
||||
// check if any items need to be lowered:
|
||||
if ($parent) {
|
||||
foreach ($_gmenu[$parent]["children"] as $key => $item) {
|
||||
if (strstr($item, $path)) {
|
||||
// remove the item from its parent:
|
||||
unset($_gmenu[$parent]["children"][$key]);
|
||||
|
||||
// add the item to its new parent:
|
||||
$_gmenu[$path]["children"][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add the menu to the best matching parent:
|
||||
$_gmenu[$parent]["children"][] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
function menu_item($in_path) {
|
||||
|
@ -40,38 +50,33 @@ function menu_item($in_path) {
|
|||
** by an image, this would be the function to customize.
|
||||
*/
|
||||
$trail = menu_trail();
|
||||
if (end($trail) == $in_path)
|
||||
return t($_gmenu[$in_path]["title"]);
|
||||
else
|
||||
return "<a href=\"".url($in_path)."\">". t($_gmenu[$in_path]["title"]) ."</a>";
|
||||
}
|
||||
if (end($trail) == $in_path) {
|
||||
$css = " class=\"current\"";
|
||||
}
|
||||
|
||||
function query_string() {
|
||||
return $GLOBALS["q"];
|
||||
return "<a href=\"". url($in_path) ."\"$css>". t($_gmenu[$in_path]["title"]) ."</a>";
|
||||
}
|
||||
|
||||
function menu_trail() {
|
||||
global $_gmenu;
|
||||
static $_gmenu_trail; // cache
|
||||
global $_gmenu, $q;
|
||||
static $trail; // cache
|
||||
|
||||
if (!isset($_gmenu_trail)) {
|
||||
$_gmenu_trail = array();
|
||||
$cuqs = query_string();
|
||||
if (empty($trail)) {
|
||||
$trail = array();
|
||||
$path = $q;
|
||||
|
||||
while (!empty($cuqs) && !isset($_gmenu[$cuqs])) {
|
||||
$cuqs = substr($cuqs, 0, strrpos($cuqs, "/"));
|
||||
while ($path) {
|
||||
if ($_gmenu[$path]) {
|
||||
$trail[] = $path;
|
||||
}
|
||||
|
||||
$path = substr($path, 0, strrpos($path, "/"));
|
||||
}
|
||||
|
||||
if (!empty($cuqs)) {
|
||||
do {
|
||||
$_gmenu_trail[] = $cuqs;
|
||||
$cuqs = substr($cuqs, 0, strrpos($cuqs, "/"));
|
||||
} while (!empty($cuqs) && isset($_gmenu[$cuqs]));
|
||||
}
|
||||
$_gmenu_trail = array_reverse($_gmenu_trail);
|
||||
$trail = array_reverse($trail);
|
||||
}
|
||||
|
||||
return $_gmenu_trail;
|
||||
return $trail;
|
||||
}
|
||||
|
||||
function menu_path() {
|
||||
|
@ -84,7 +89,7 @@ function menu_path() {
|
|||
$links[] = menu_item($item);
|
||||
}
|
||||
|
||||
return implode(" > ", $links);
|
||||
return implode(" » ", $links);
|
||||
}
|
||||
|
||||
function menu_help() {
|
||||
|
@ -148,12 +153,12 @@ function menu_map($parent = "") {
|
|||
}
|
||||
|
||||
function menu_execute_action() {
|
||||
global $_gmenu;
|
||||
global $_gmenu, $q;
|
||||
$trail = menu_trail();
|
||||
$selected_menu = array_pop($trail);
|
||||
|
||||
if ($_gmenu[$selected_menu]["callback"]) {
|
||||
$arg = substr(query_string(), strlen($selected_menu) + 1);
|
||||
$arg = substr($q, strlen($selected_menu) + 1);
|
||||
if (empty($arg)) {
|
||||
return call_user_func($_gmenu[$selected_menu]["callback"]);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ h1 {
|
|||
color: #006;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.3em;
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
color: #006;
|
||||
margin: 0;
|
||||
|
@ -92,6 +92,9 @@ hr {
|
|||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
#menu li a.current {
|
||||
color: #000;
|
||||
}
|
||||
#menu li a:hover {
|
||||
color: #009;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ function status($message) {
|
|||
|
||||
function admin_link($type) {
|
||||
if ($type == "admin") {
|
||||
menu("admin", "Administration", NULL);
|
||||
menu("admin/sitemap", "sitemap", "sitemap_callback", NULL, 8);
|
||||
}
|
||||
}
|
||||
|
@ -54,10 +55,7 @@ function admin_page() {
|
|||
print "<div id=\"main\">";
|
||||
|
||||
if ($path = menu_path()) {
|
||||
print "<h2>". l(t("Administration"), "admin") ." $path</h2>";
|
||||
}
|
||||
else {
|
||||
print "<h2>". t("Administration") ."</h2>";
|
||||
print "<h2>$path</h2>";
|
||||
}
|
||||
|
||||
if ($help = menu_help()) {
|
||||
|
|
|
@ -39,8 +39,8 @@ function import_link($type) {
|
|||
$help["bundles"] = "Bundles provide a generalized way of creating composite feeds. They allow you, for example, to combine various sport-related feeds into one bundle called <i>Sport</i>.";
|
||||
menu("admin/syndication", "content syndication", NULL, NULL, 5);
|
||||
menu("admin/syndication/news", "news aggregation", "import_admin", $help["general"]);
|
||||
menu("admin/syndication/news/add feed", "add new feed", "import_admin", NULL, 2);
|
||||
menu("admin/syndication/news/add bundle", "add new bundle", "import_admin", $help["bundles"], 3);
|
||||
menu("admin/syndication/news/add/feed", "add new feed", "import_admin", NULL, 2);
|
||||
menu("admin/syndication/news/add/bundle", "add new bundle", "import_admin", $help["bundles"], 3);
|
||||
menu("admin/syndication/news/tag", "tag news items", "import_admin", NULL, 4);
|
||||
menu("admin/syndication/news/help", "help", "import_help", NULL, 9);
|
||||
}
|
||||
|
@ -489,12 +489,13 @@ function import_admin() {
|
|||
}
|
||||
|
||||
switch ($op) {
|
||||
case "add feed":
|
||||
print import_form_feed();
|
||||
break;
|
||||
case "add bundle":
|
||||
print import_form_bundle();
|
||||
break;
|
||||
case "add":
|
||||
if (arg(4) == "bundle") {
|
||||
print import_form_bundle();
|
||||
}
|
||||
else {
|
||||
print import_form_feed();
|
||||
}
|
||||
case "edit":
|
||||
if (arg(4) == "bundle") {
|
||||
print import_form_bundle(import_get_bundle(arg(5)));
|
||||
|
@ -522,7 +523,7 @@ function import_admin() {
|
|||
$edit["title"] = 0;
|
||||
// fall through:
|
||||
case "Submit":
|
||||
if (arg(3) == "add bundle") {
|
||||
if (arg(4) == "bundle") {
|
||||
print status(import_save_bundle($edit));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -39,8 +39,8 @@ function import_link($type) {
|
|||
$help["bundles"] = "Bundles provide a generalized way of creating composite feeds. They allow you, for example, to combine various sport-related feeds into one bundle called <i>Sport</i>.";
|
||||
menu("admin/syndication", "content syndication", NULL, NULL, 5);
|
||||
menu("admin/syndication/news", "news aggregation", "import_admin", $help["general"]);
|
||||
menu("admin/syndication/news/add feed", "add new feed", "import_admin", NULL, 2);
|
||||
menu("admin/syndication/news/add bundle", "add new bundle", "import_admin", $help["bundles"], 3);
|
||||
menu("admin/syndication/news/add/feed", "add new feed", "import_admin", NULL, 2);
|
||||
menu("admin/syndication/news/add/bundle", "add new bundle", "import_admin", $help["bundles"], 3);
|
||||
menu("admin/syndication/news/tag", "tag news items", "import_admin", NULL, 4);
|
||||
menu("admin/syndication/news/help", "help", "import_help", NULL, 9);
|
||||
}
|
||||
|
@ -489,12 +489,13 @@ function import_admin() {
|
|||
}
|
||||
|
||||
switch ($op) {
|
||||
case "add feed":
|
||||
print import_form_feed();
|
||||
break;
|
||||
case "add bundle":
|
||||
print import_form_bundle();
|
||||
break;
|
||||
case "add":
|
||||
if (arg(4) == "bundle") {
|
||||
print import_form_bundle();
|
||||
}
|
||||
else {
|
||||
print import_form_feed();
|
||||
}
|
||||
case "edit":
|
||||
if (arg(4) == "bundle") {
|
||||
print import_form_bundle(import_get_bundle(arg(5)));
|
||||
|
@ -522,7 +523,7 @@ function import_admin() {
|
|||
$edit["title"] = 0;
|
||||
// fall through:
|
||||
case "Submit":
|
||||
if (arg(3) == "add bundle") {
|
||||
if (arg(4) == "bundle") {
|
||||
print status(import_save_bundle($edit));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -39,8 +39,8 @@ function import_link($type) {
|
|||
$help["bundles"] = "Bundles provide a generalized way of creating composite feeds. They allow you, for example, to combine various sport-related feeds into one bundle called <i>Sport</i>.";
|
||||
menu("admin/syndication", "content syndication", NULL, NULL, 5);
|
||||
menu("admin/syndication/news", "news aggregation", "import_admin", $help["general"]);
|
||||
menu("admin/syndication/news/add feed", "add new feed", "import_admin", NULL, 2);
|
||||
menu("admin/syndication/news/add bundle", "add new bundle", "import_admin", $help["bundles"], 3);
|
||||
menu("admin/syndication/news/add/feed", "add new feed", "import_admin", NULL, 2);
|
||||
menu("admin/syndication/news/add/bundle", "add new bundle", "import_admin", $help["bundles"], 3);
|
||||
menu("admin/syndication/news/tag", "tag news items", "import_admin", NULL, 4);
|
||||
menu("admin/syndication/news/help", "help", "import_help", NULL, 9);
|
||||
}
|
||||
|
@ -489,12 +489,13 @@ function import_admin() {
|
|||
}
|
||||
|
||||
switch ($op) {
|
||||
case "add feed":
|
||||
print import_form_feed();
|
||||
break;
|
||||
case "add bundle":
|
||||
print import_form_bundle();
|
||||
break;
|
||||
case "add":
|
||||
if (arg(4) == "bundle") {
|
||||
print import_form_bundle();
|
||||
}
|
||||
else {
|
||||
print import_form_feed();
|
||||
}
|
||||
case "edit":
|
||||
if (arg(4) == "bundle") {
|
||||
print import_form_bundle(import_get_bundle(arg(5)));
|
||||
|
@ -522,7 +523,7 @@ function import_admin() {
|
|||
$edit["title"] = 0;
|
||||
// fall through:
|
||||
case "Submit":
|
||||
if (arg(3) == "add bundle") {
|
||||
if (arg(4) == "bundle") {
|
||||
print status(import_save_bundle($edit));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -32,7 +32,7 @@ function taxonomy_link($type, $node = NULL) {
|
|||
$help["vocabulary"] = "When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node of content (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories.";
|
||||
|
||||
menu("admin/taxonomy", "taxonomy", "taxonomy_admin", $help["taxonomy"], 3);
|
||||
menu("admin/taxonomy/addvocabulary", "create new vocabulary", "taxonomy_admin", $help["vocabulary"]);
|
||||
menu("admin/taxonomy/add/vocabulary", "create new vocabulary", "taxonomy_admin", $help["vocabulary"]);
|
||||
menu("admin/taxonomy/help", "help", "taxonomy_admin", NULL, 9);
|
||||
}
|
||||
else if ($type == "taxonomy terms" && $node != NULL) {
|
||||
|
@ -134,7 +134,7 @@ function _taxonomy_confirm_del_vocabulary($vid) {
|
|||
}
|
||||
|
||||
function taxonomy_form_term($edit = array()) {
|
||||
$vocabulary_id = isset($edit["vid"]) ? $edit["vid"] : arg(3);
|
||||
$vocabulary_id = isset($edit["vid"]) ? $edit["vid"] : arg(4);
|
||||
$vocabulary = taxonomy_get_vocabulary($vocabulary_id);
|
||||
|
||||
$form = form_textfield(t("Term name"), "name", $edit["name"], 50, 64, t("Required") . ". " . t("The name for this term. Example: 'Linux'."));
|
||||
|
@ -268,13 +268,13 @@ function taxonomy_overview() {
|
|||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $vocabulary) {
|
||||
$links = array();
|
||||
$rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/editvocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/addterm/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
|
||||
$rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/add/term/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
|
||||
|
||||
$tree = taxonomy_get_tree($vocabulary->vid);
|
||||
if ($tree) {
|
||||
unset($data);
|
||||
foreach ($tree as $term) {
|
||||
$data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/editterm/$term->tid") .")<br />";
|
||||
$data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/edit/term/$term->tid") .")<br />";
|
||||
}
|
||||
$rows[] = array(array("data" => $data, "colspan" => 5));
|
||||
}
|
||||
|
@ -710,31 +710,31 @@ function taxonomy_admin() {
|
|||
}
|
||||
|
||||
switch ($op) {
|
||||
case "addvocabulary":
|
||||
print taxonomy_form_vocabulary();
|
||||
case "add":
|
||||
if (arg(3) == "vocabulary")
|
||||
$output .= taxonomy_form_vocabulary();
|
||||
else if (arg(3) == "term")
|
||||
$output .= taxonomy_form_term();
|
||||
break;
|
||||
case "addterm":
|
||||
print taxonomy_form_term();
|
||||
break;
|
||||
case "editvocabulary":
|
||||
print taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(3))));
|
||||
break;
|
||||
case "editterm":
|
||||
print taxonomy_form_term(object2array(taxonomy_get_term(arg(3))));
|
||||
case "edit":
|
||||
if (arg(3) == "vocabulary")
|
||||
$output .= taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(4))));
|
||||
else if (arg(3) == "term")
|
||||
$output .= taxonomy_form_term(object2array(taxonomy_get_term(arg(4))));
|
||||
break;
|
||||
case "preview":
|
||||
print taxonomy_form(arg(4));
|
||||
$output .= taxonomy_form(arg(4));
|
||||
break;
|
||||
case "help":
|
||||
print taxonomy_help();
|
||||
$output .= taxonomy_help();
|
||||
break;
|
||||
case t("Delete"):
|
||||
if (!$edit["confirm"]) {
|
||||
if (arg(3) == "vocabulary") {
|
||||
echo _taxonomy_confirm_del_vocabulary($edit["vid"]);
|
||||
$output .= _taxonomy_confirm_del_vocabulary($edit["vid"]);
|
||||
}
|
||||
else {
|
||||
echo _taxonomy_confirm_del_term($edit["tid"]);
|
||||
$output .= _taxonomy_confirm_del_term($edit["tid"]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -743,31 +743,31 @@ function taxonomy_admin() {
|
|||
// fall through:
|
||||
}
|
||||
case t("Submit"):
|
||||
if (arg(2) == "addvocabulary" || arg(2) == "editvocabulary") {
|
||||
print status(taxonomy_save_vocabulary($edit));
|
||||
if (arg(3) == "vocabulary") {
|
||||
$output .= status(taxonomy_save_vocabulary($edit));
|
||||
}
|
||||
else {
|
||||
print status(taxonomy_save_term($edit));
|
||||
return status(taxonomy_save_term($edit));
|
||||
if (!$edit["tid"]) {
|
||||
// if INSERT show form again
|
||||
print taxonomy_form_term();
|
||||
$output .= taxonomy_form_term();
|
||||
break;
|
||||
}
|
||||
// else (UPDATE or DELETE) fall through
|
||||
}
|
||||
// fall through:
|
||||
default:
|
||||
print taxonomy_overview();
|
||||
$output .= taxonomy_overview();
|
||||
}
|
||||
}
|
||||
else {
|
||||
print message_access();
|
||||
$output .= message_access();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function taxonomy_help() {
|
||||
?>
|
||||
|
||||
?>
|
||||
<h3>Background</h3>
|
||||
<p>Classifying nodes allows for the organization of content into categories and subcategories of description. These categories can be used to organize and retrieve similarly described content. Drupal's <i>taxonomy.module</i> is an extremely flexible classification system that allows for multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically). For details about <a href="http://www.eleganthack.com/archives/002165.html#002165">classification types</a> and insight into the development of <i>taxonomy.module</i>, see this <a href="http://www.drupal.org/node/view/55">drupal.org discussion</a>.</p>
|
||||
|
||||
|
@ -818,7 +818,6 @@ function taxonomy_help() {
|
|||
<i><a name="parent"></a>Parent</i><br />Required. Select the term under which this term is a subset -- the branch of the hierarchy that this term belongs under. This is also known as the "Broader term" indicator used in thesauri.<br />
|
||||
<br />
|
||||
<i><a name="synonyms"></a>Synonyms</i><br />Optional. Enter synonyms for this term, one synonym per line. Synonyms can be used for variant spellings, acronyms, and other terms that have the same meaning as the added term, but which are not explicitly listed in this thesaurus (i.e. <i>unauthorized terms</i>).</p>
|
||||
|
||||
<h3>Displaying nodes organized by term(s)</h3>
|
||||
<p>In order to view the nodes associated with a term or a collection of terms, you should browse to a properly formed URL. For example, see <a href="<?php print url("taxonomy/page/or/1,2"); ?>"><?php print url("taxonomy/page/or/1,2"); ?></a>. Taxonomy URLs always contain a term ID or list of term IDs at the end of the URL (aka <i>querystring</i>). You may learn the term ID for a given term by hovering over that term in the <?php echo l("taxonomy overview", "admin/taxonomy") ?> page in the Admin and noting the number after the querystring parameter called <i>tid</i>. If you wish to see nodes from a collection of term IDs, separate each term ID with a comma. Also, the name of the querystring parameter may be <i>or</i> or <i>and</i>: <i>or</i> shows nodes which appear in <b>any</b> of the term IDs while <i>and</i> shows nodes in <b>all</b> the specified term IDs. Thus, <i>or</i> is less specific than <i>and</i>.</p>
|
||||
|
||||
|
@ -826,4 +825,4 @@ function taxonomy_help() {
|
|||
<p>Every term, or collection of terms, provides an <a href="http://backend.userland.com/stories/rss091">RSS</a> feed to which interested users may subscribe. The URL format for an sample RSS feed is <a href="<?php print url("node/feed/or/1,2"); ?>"><?php print url("node/feed/or/1,2"); ?></a>.</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
?>
|
|
@ -32,7 +32,7 @@ function taxonomy_link($type, $node = NULL) {
|
|||
$help["vocabulary"] = "When you create a controlled vocabulary you are creating a set of terms to use for describing content (known as descriptors in indexing lingo). Drupal allows you to describe each node of content (blog, story, etc.) using one or many of these terms. For simple implementations, you might create a set of categories without subcategories, similar to Slashdot.org's or Kuro5hin.org's sections. For more complex implementations, you might create a hierarchical list of categories.";
|
||||
|
||||
menu("admin/taxonomy", "taxonomy", "taxonomy_admin", $help["taxonomy"], 3);
|
||||
menu("admin/taxonomy/addvocabulary", "create new vocabulary", "taxonomy_admin", $help["vocabulary"]);
|
||||
menu("admin/taxonomy/add/vocabulary", "create new vocabulary", "taxonomy_admin", $help["vocabulary"]);
|
||||
menu("admin/taxonomy/help", "help", "taxonomy_admin", NULL, 9);
|
||||
}
|
||||
else if ($type == "taxonomy terms" && $node != NULL) {
|
||||
|
@ -134,7 +134,7 @@ function _taxonomy_confirm_del_vocabulary($vid) {
|
|||
}
|
||||
|
||||
function taxonomy_form_term($edit = array()) {
|
||||
$vocabulary_id = isset($edit["vid"]) ? $edit["vid"] : arg(3);
|
||||
$vocabulary_id = isset($edit["vid"]) ? $edit["vid"] : arg(4);
|
||||
$vocabulary = taxonomy_get_vocabulary($vocabulary_id);
|
||||
|
||||
$form = form_textfield(t("Term name"), "name", $edit["name"], 50, 64, t("Required") . ". " . t("The name for this term. Example: 'Linux'."));
|
||||
|
@ -268,13 +268,13 @@ function taxonomy_overview() {
|
|||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $vocabulary) {
|
||||
$links = array();
|
||||
$rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/editvocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/addterm/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
|
||||
$rows[] = array($vocabulary->name, array("data" => $vocabulary->types, "align" => "center"), l(t("edit vocabulary"), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t("add term"), "admin/taxonomy/add/term/$vocabulary->vid"), l(t("preview form"), "admin/taxonomy/preview/vocabulary/$vocabulary->vid"));
|
||||
|
||||
$tree = taxonomy_get_tree($vocabulary->vid);
|
||||
if ($tree) {
|
||||
unset($data);
|
||||
foreach ($tree as $term) {
|
||||
$data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/editterm/$term->tid") .")<br />";
|
||||
$data .= _taxonomy_depth($term->depth) ." ". $term->name ." (". l(t("edit term"), "admin/taxonomy/edit/term/$term->tid") .")<br />";
|
||||
}
|
||||
$rows[] = array(array("data" => $data, "colspan" => 5));
|
||||
}
|
||||
|
@ -710,31 +710,31 @@ function taxonomy_admin() {
|
|||
}
|
||||
|
||||
switch ($op) {
|
||||
case "addvocabulary":
|
||||
print taxonomy_form_vocabulary();
|
||||
case "add":
|
||||
if (arg(3) == "vocabulary")
|
||||
$output .= taxonomy_form_vocabulary();
|
||||
else if (arg(3) == "term")
|
||||
$output .= taxonomy_form_term();
|
||||
break;
|
||||
case "addterm":
|
||||
print taxonomy_form_term();
|
||||
break;
|
||||
case "editvocabulary":
|
||||
print taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(3))));
|
||||
break;
|
||||
case "editterm":
|
||||
print taxonomy_form_term(object2array(taxonomy_get_term(arg(3))));
|
||||
case "edit":
|
||||
if (arg(3) == "vocabulary")
|
||||
$output .= taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(4))));
|
||||
else if (arg(3) == "term")
|
||||
$output .= taxonomy_form_term(object2array(taxonomy_get_term(arg(4))));
|
||||
break;
|
||||
case "preview":
|
||||
print taxonomy_form(arg(4));
|
||||
$output .= taxonomy_form(arg(4));
|
||||
break;
|
||||
case "help":
|
||||
print taxonomy_help();
|
||||
$output .= taxonomy_help();
|
||||
break;
|
||||
case t("Delete"):
|
||||
if (!$edit["confirm"]) {
|
||||
if (arg(3) == "vocabulary") {
|
||||
echo _taxonomy_confirm_del_vocabulary($edit["vid"]);
|
||||
$output .= _taxonomy_confirm_del_vocabulary($edit["vid"]);
|
||||
}
|
||||
else {
|
||||
echo _taxonomy_confirm_del_term($edit["tid"]);
|
||||
$output .= _taxonomy_confirm_del_term($edit["tid"]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -743,31 +743,31 @@ function taxonomy_admin() {
|
|||
// fall through:
|
||||
}
|
||||
case t("Submit"):
|
||||
if (arg(2) == "addvocabulary" || arg(2) == "editvocabulary") {
|
||||
print status(taxonomy_save_vocabulary($edit));
|
||||
if (arg(3) == "vocabulary") {
|
||||
$output .= status(taxonomy_save_vocabulary($edit));
|
||||
}
|
||||
else {
|
||||
print status(taxonomy_save_term($edit));
|
||||
return status(taxonomy_save_term($edit));
|
||||
if (!$edit["tid"]) {
|
||||
// if INSERT show form again
|
||||
print taxonomy_form_term();
|
||||
$output .= taxonomy_form_term();
|
||||
break;
|
||||
}
|
||||
// else (UPDATE or DELETE) fall through
|
||||
}
|
||||
// fall through:
|
||||
default:
|
||||
print taxonomy_overview();
|
||||
$output .= taxonomy_overview();
|
||||
}
|
||||
}
|
||||
else {
|
||||
print message_access();
|
||||
$output .= message_access();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function taxonomy_help() {
|
||||
?>
|
||||
|
||||
?>
|
||||
<h3>Background</h3>
|
||||
<p>Classifying nodes allows for the organization of content into categories and subcategories of description. These categories can be used to organize and retrieve similarly described content. Drupal's <i>taxonomy.module</i> is an extremely flexible classification system that allows for multiple lists of categories for classification (controlled vocabularies) and offers the possibility of creating thesauri (controlled vocabularies that indicate the relationship of terms) and taxonomies (controlled vocabularies where relationships are indicated hierarchically). For details about <a href="http://www.eleganthack.com/archives/002165.html#002165">classification types</a> and insight into the development of <i>taxonomy.module</i>, see this <a href="http://www.drupal.org/node/view/55">drupal.org discussion</a>.</p>
|
||||
|
||||
|
@ -818,7 +818,6 @@ function taxonomy_help() {
|
|||
<i><a name="parent"></a>Parent</i><br />Required. Select the term under which this term is a subset -- the branch of the hierarchy that this term belongs under. This is also known as the "Broader term" indicator used in thesauri.<br />
|
||||
<br />
|
||||
<i><a name="synonyms"></a>Synonyms</i><br />Optional. Enter synonyms for this term, one synonym per line. Synonyms can be used for variant spellings, acronyms, and other terms that have the same meaning as the added term, but which are not explicitly listed in this thesaurus (i.e. <i>unauthorized terms</i>).</p>
|
||||
|
||||
<h3>Displaying nodes organized by term(s)</h3>
|
||||
<p>In order to view the nodes associated with a term or a collection of terms, you should browse to a properly formed URL. For example, see <a href="<?php print url("taxonomy/page/or/1,2"); ?>"><?php print url("taxonomy/page/or/1,2"); ?></a>. Taxonomy URLs always contain a term ID or list of term IDs at the end of the URL (aka <i>querystring</i>). You may learn the term ID for a given term by hovering over that term in the <?php echo l("taxonomy overview", "admin/taxonomy") ?> page in the Admin and noting the number after the querystring parameter called <i>tid</i>. If you wish to see nodes from a collection of term IDs, separate each term ID with a comma. Also, the name of the querystring parameter may be <i>or</i> or <i>and</i>: <i>or</i> shows nodes which appear in <b>any</b> of the term IDs while <i>and</i> shows nodes in <b>all</b> the specified term IDs. Thus, <i>or</i> is less specific than <i>and</i>.</p>
|
||||
|
||||
|
@ -826,4 +825,4 @@ function taxonomy_help() {
|
|||
<p>Every term, or collection of terms, provides an <a href="http://backend.userland.com/stories/rss091">RSS</a> feed to which interested users may subscribe. The URL format for an sample RSS feed is <a href="<?php print url("node/feed/or/1,2"); ?>"><?php print url("node/feed/or/1,2"); ?></a>.</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
?>
|
Loading…
Reference in New Issue