summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Starbow2009-02-16 07:10:23 (GMT)
committerTao Starbow2009-02-16 07:10:23 (GMT)
commite85d8b53910fe0b40b784c1b77c5e7f572569880 (patch)
treedb6979197f3a6df6865f23dc2afcc11ac7ea2990
parent32a48eb1386ece3395e2e8d2970a0464820cf90f (diff)
* http://drupal.org/node/345353 (alaken) - fix issue with underscores in content names.5.x-1.0-beta2
* backport of http://drupal.org/node/359524 by Cloudy - use human type names in link text.
-rw-r--r--CHANGELOG.txt2
-rw-r--r--popups_reference.module14
2 files changed, 4 insertions, 12 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 14663cb..8bc6c74 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -2,5 +2,7 @@
Bug Fixes
* Getting collapsable fieldsets working for in autofill popups.
* http://drupal.org/node/345353: Getting autofill working w/out page refresh.
+ * http://drupal.org/node/345353 (alaken) - fix issue with underscores in content names.
+ * backport of http://drupal.org/node/359524 by Cloudy - use human type names in link text.
Notes
* Needs Popups API 1.0-beta2 or better. \ No newline at end of file
diff --git a/popups_reference.module b/popups_reference.module
index 6df01eb..19274e8 100644
--- a/popups_reference.module
+++ b/popups_reference.module
@@ -13,16 +13,11 @@ function popups_reference_form_alter($form_id, &$form) {
if (isset($form['type'])) {
$node = $form['#node'];
if ($form['type']['#value'] .'_node_form' == $form_id) {
-//dsm($form_id, 'form_id');
$fields = content_fields();
-// dsm($form);
foreach ($form as $key => $item) {
-//firep($key);
if (is_array($item)) {
$type = $item['#type'];
-// dsm("$key, $type");
if ($type == 'fieldset') { // loop through all the subitems.
-// firep($item, $key);
foreach ($form[$key] as $subkey => $subitem) {
popups_reference_alter_item($form[$key], $subkey, $subitem, $fields);
}
@@ -40,12 +35,9 @@ function popups_reference_form_alter($form_id, &$form) {
function popups_reference_alter_item(&$form, $key, $item, $fields) {
$field_name = strstr($key, 'field_');
-//dsm($key .', '. $field_name .', '. $fields[$field_name] .', '. $fields[$$field_name]['type']);
-//dsm($key .', '. $field_name .', '. $fields[$field_name] .', '. $fields[$field_name]['type']);
if (isset($fields[$field_name]) && $fields[$field_name]['type'] == 'nodereference') {
$type = $form['type']['#value'];
$field = content_fields($field_name, $form['type']['#value']);
-//dsm($key .', '. $field['widget']['type']);
if ($field['widget']['type'] == 'nodereference_select') {
$id = 'popups-reference-' . _popups_reference_counter();
@@ -79,8 +71,6 @@ function _popups_reference_links($field, $src_type, $id=null) {
);
}
else { // Creating link to autofill box.
-// $pclass = 'popups';
-// popups_add_popups();
$pclass = 'popups-reference-autofill';
popups_add_popups(
array('.'.$pclass=>array(
@@ -93,8 +83,8 @@ function _popups_reference_links($field, $src_type, $id=null) {
$all_types = node_get_types();
foreach ($field['referenceable_types'] as $type => $value) {
if (!empty($value) && user_access("create $type content")) {
- $path = "node/add/$type";
- $links[] = l("Add $type", $path, array('class' => $pclass), "destination=node/add/$src_type");
+ $path = "node/add/". strtr($type, '_', '-');
+ $links[] = l("Add ". $all_types[$type]->name, $path, array('class' => $pclass), "destination=node/add/" . strtr($src_type, '_', '-'));
}
}
return $links;