Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
a2d62970
Commit
a2d62970
authored
May 05, 2010
by
webchick
Browse files
#771922
by andypost: Remove t() from schema description of picture field.
parent
adc9bc18
Changes
11
Hide whitespace changes
Inline
Side-by-side
modules/book/book.install
View file @
a2d62970
...
...
@@ -37,6 +37,7 @@ function _book_install_type_create() {
$book_node_type
=
node_type_set_defaults
(
$book_node_type
);
node_type_save
(
$book_node_type
);
node_add_body_field
(
$book_node_type
);
// Default to not promoted.
variable_set
(
'node_options_book'
,
array
(
'status'
));
// Use this default type for adding content to books.
...
...
modules/forum/forum.install
View file @
a2d62970
...
...
@@ -80,6 +80,10 @@ function forum_enable() {
$term
=
(
object
)
$edit
;
taxonomy_term_save
(
$term
);
}
// Ensure the forum node type is available.
node_types_rebuild
();
$types
=
node_type_get_types
();
node_add_body_field
(
$types
[
'forum'
]);
}
/**
...
...
modules/node/content_types.inc
View file @
a2d62970
...
...
@@ -160,12 +160,6 @@ function node_type_form($form, &$form_state, $type = NULL) {
$form
[
'submission'
][
'title_label'
][
'#description'
]
=
t
(
'This content type does not have a title field.'
);
$form
[
'submission'
][
'title_label'
][
'#required'
]
=
FALSE
;
}
$form
[
'submission'
][
'body_label'
]
=
array
(
'#title'
=>
t
(
'Body field label'
),
'#type'
=>
'textfield'
,
'#default_value'
=>
isset
(
$type
->
body_label
)
?
$type
->
body_label
:
''
,
'#description'
=>
t
(
'To remove the body field, remove text and leave blank.'
),
);
$form
[
'submission'
][
'node_preview'
]
=
array
(
'#type'
=>
'radios'
,
'#title'
=>
t
(
'Preview before submitting'
),
...
...
@@ -322,12 +316,9 @@ function node_type_form_submit($form, &$form_state) {
$type
->
description
=
$form_state
[
'values'
][
'description'
];
$type
->
help
=
$form_state
[
'values'
][
'help'
];
$type
->
title_label
=
$form_state
[
'values'
][
'title_label'
];
$type
->
body_label
=
$form_state
[
'values'
][
'body_label'
];
// title_label is required in core; has_title will always be true, unless a
// module alters the title field.
$type
->
has_title
=
(
$type
->
title_label
!=
''
);
$type
->
has_body
=
(
$type
->
body_label
!=
''
);
$type
->
base
=
!
empty
(
$form_state
[
'values'
][
'base'
])
?
$form_state
[
'values'
][
'base'
]
:
'node_content'
;
$type
->
custom
=
$form_state
[
'values'
][
'custom'
];
...
...
@@ -372,6 +363,7 @@ function node_type_form_submit($form, &$form_state) {
node_types_rebuild
();
menu_rebuild
();
node_add_body_field
(
$type
);
$t_args
=
array
(
'%name'
=>
$type
->
name
);
if
(
$status
==
SAVED_UPDATED
)
{
...
...
modules/node/content_types.js
View file @
a2d62970
...
...
@@ -7,7 +7,6 @@ Drupal.behaviors.contentTypes = {
$
(
'
fieldset#edit-submission
'
,
context
).
drupalSetSummary
(
function
(
context
)
{
var
vals
=
[];
vals
.
push
(
Drupal
.
checkPlain
(
$
(
'
#edit-title-label
'
,
context
).
val
())
||
Drupal
.
t
(
'
Requires a title
'
));
vals
.
push
(
Drupal
.
checkPlain
(
$
(
'
#edit-body-label
'
,
context
).
val
())
||
Drupal
.
t
(
'
No body
'
));
return
vals
.
join
(
'
,
'
);
});
$
(
'
fieldset#edit-workflow
'
,
context
).
drupalSetSummary
(
function
(
context
)
{
...
...
modules/node/node.api.php
View file @
a2d62970
...
...
@@ -771,10 +771,6 @@ function hook_node_view_alter(&$build) {
* field. Optional (defaults to TRUE).
* - "title_label": the label for the title field of this content type.
* Optional (defaults to 'Title').
* - "has_body": boolean indicating whether or not this node type has a body
* field. Optional (defaults to TRUE).
* - "body_label": the label for the body field of this content type. Optional
* (defaults to 'Body').
* - "locked": boolean indicating whether the administrator can change the
* machine name of this type. FALSE = changeable (not locked),
* TRUE = unchangeable (locked). Optional (defaults to TRUE).
...
...
@@ -986,17 +982,6 @@ function hook_prepare($node) {
function
hook_form
(
$node
,
$form_state
)
{
$type
=
node_type_get_type
(
$node
);
$form
[
'title'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
check_plain
(
$type
->
title_label
),
'#required'
=>
TRUE
,
);
$form
[
'body'
]
=
array
(
'#type'
=>
'textarea'
,
'#title'
=>
check_plain
(
$type
->
body_label
),
'#rows'
=>
20
,
'#required'
=>
TRUE
,
);
$form
[
'field1'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Custom field'
),
...
...
modules/node/node.install
View file @
a2d62970
...
...
@@ -306,21 +306,6 @@ function node_schema() {
'default'
=>
''
,
'translatable'
=>
TRUE
,
),
'has_body'
=>
array
(
'description'
=>
'Boolean indicating whether this type has the body field attached.'
,
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
TRUE
,
'size'
=>
'tiny'
,
),
'body_label'
=>
array
(
'description'
=>
'The label displayed for the body field on the edit form.'
,
'type'
=>
'varchar'
,
'length'
=>
255
,
'not null'
=>
TRUE
,
'default'
=>
''
,
'translatable'
=>
TRUE
,
),
'custom'
=>
array
(
'description'
=>
'A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE).'
,
'type'
=>
'int'
,
...
...
@@ -552,7 +537,7 @@ function node_update_7006(&$sandbox) {
foreach
(
$revisions
as
$revision
)
{
$found
=
TRUE
;
if
(
$node_types
[
$revision
->
type
]
->
has_body
)
{
if
(
$
sandbox
[
'
node_types
_info'
]
[
$revision
->
type
]
[
'
has_body
'
]
)
{
$node
=
(
object
)
array
(
'nid'
=>
$revision
->
nid
,
'vid'
=>
$revision
->
vid
,
...
...
modules/node/node.module
View file @
a2d62970
...
...
@@ -496,8 +496,6 @@ function node_type_save($info) {
'base'
=>
(
string
)
$type
->
base
,
'has_title'
=>
(
int
)
$type
->
has_title
,
'title_label'
=>
(
string
)
$type
->
title_label
,
'has_body'
=>
(
int
)
$type
->
has_body
,
'body_label'
=>
(
string
)
$type
->
body_label
,
'description'
=>
(
string
)
$type
->
description
,
'help'
=>
(
string
)
$type
->
help
,
'custom'
=>
(
int
)
$type
->
custom
,
...
...
@@ -514,7 +512,6 @@ function node_type_save($info) {
if
(
!
empty
(
$type
->
old_type
)
&&
$type
->
old_type
!=
$type
->
type
)
{
field_attach_rename_bundle
(
'node'
,
$type
->
old_type
,
$type
->
type
);
}
node_configure_fields
(
$type
);
module_invoke_all
(
'node_type_update'
,
$type
);
$status
=
SAVED_UPDATED
;
}
...
...
@@ -525,7 +522,7 @@ function node_type_save($info) {
->
execute
();
field_attach_create_bundle
(
'node'
,
$type
->
type
);
node_configure_fields
(
$type
);
module_invoke_all
(
'node_type_insert'
,
$type
);
$status
=
SAVED_NEW
;
}
...
...
@@ -537,60 +534,48 @@ function node_type_save($info) {
}
/**
*
Manage the field(s) for
a node type.
*
Add default body field to
a node type.
*
* Currently, the node module manages a single Field API field,
* 'body'. If $type->has_body is true, this function ensures the
* 'body' field exists and creates an instance of it for the bundle
* $type->type (e.g. 'page', 'story', ...). If $type->has_body is
* false, this function removes the instance (if it exists) for the
* 'body' field on $type->type.
* @param $type
* The node type name.
* @param $label
* The label for the body instance.
*/
function
node_
configure
_field
s
(
$type
)
{
function
node_
add_body
_field
(
$type
,
$label
=
'Body'
)
{
// Add or remove the body field, as needed.
$field
=
field_info_field
(
'body'
);
$instance
=
field_info_instance
(
'node'
,
'body'
,
$type
->
type
);
if
(
$type
->
has_body
)
{
if
(
empty
(
$field
))
{
$field
=
array
(
'field_name'
=>
'body'
,
'type'
=>
'text_with_summary'
,
'entity_types'
=>
array
(
'node'
),
'translatable'
=>
TRUE
,
);
$field
=
field_create_field
(
$field
);
}
if
(
empty
(
$instance
))
{
$instance
=
array
(
'field_name'
=>
'body'
,
'entity_type'
=>
'node'
,
'bundle'
=>
$type
->
type
,
'label'
=>
$type
->
body_label
,
'widget_type'
=>
'text_textarea_with_summary'
,
'settings'
=>
array
(
'display_summary'
=>
TRUE
),
// Define default formatters for the teaser and full view.
'display'
=>
array
(
'full'
=>
array
(
'label'
=>
'hidden'
,
'type'
=>
'text_default'
,
),
'teaser'
=>
array
(
'label'
=>
'hidden'
,
'type'
=>
'text_summary_or_trimmed'
,
),
if
(
empty
(
$field
))
{
$field
=
array
(
'field_name'
=>
'body'
,
'type'
=>
'text_with_summary'
,
'entity_types'
=>
array
(
'node'
),
'translatable'
=>
TRUE
,
);
$field
=
field_create_field
(
$field
);
}
if
(
empty
(
$instance
))
{
$instance
=
array
(
'field_name'
=>
'body'
,
'entity_type'
=>
'node'
,
'bundle'
=>
$type
->
type
,
'label'
=>
$label
,
'widget_type'
=>
'text_textarea_with_summary'
,
'settings'
=>
array
(
'display_summary'
=>
TRUE
),
// Define default formatters for the teaser and full view.
'display'
=>
array
(
'full'
=>
array
(
'label'
=>
'hidden'
,
'type'
=>
'text_default'
,
),
);
field_create_instance
(
$instance
);
}
else
{
$instance
[
'label'
]
=
$type
->
body_label
;
$instance
[
'settings'
][
'display_summary'
]
=
TRUE
;
field_update_instance
(
$instance
);
}
}
elseif
(
!
empty
(
$instance
))
{
field_delete_instance
(
$instance
);
'teaser'
=>
array
(
'label'
=>
'hidden'
,
'type'
=>
'text_summary_or_trimmed'
,
),
),
);
field_create_instance
(
$instance
);
}
}
...
...
@@ -737,14 +722,13 @@ function node_type_set_defaults($info = array()) {
$type
->
base
=
''
;
$type
->
description
=
''
;
$type
->
help
=
''
;
$type
->
has_title
=
1
;
$type
->
has_body
=
1
;
$type
->
title_label
=
t
(
'Title'
);
$type
->
body_label
=
t
(
'Body'
);
$type
->
custom
=
0
;
$type
->
modified
=
0
;
$type
->
locked
=
1
;
$type
->
is_new
=
1
;
$type
->
has_title
=
1
;
$type
->
title_label
=
'Title'
;
}
$new_type
=
clone
$type
;
...
...
@@ -752,13 +736,10 @@ function node_type_set_defaults($info = array()) {
foreach
(
$info
as
$key
=>
$data
)
{
$new_type
->
$key
=
$data
;
}
// If the type has no title
or body
, set an empty label.
// If the type has no title, set an empty label.
if
(
!
$new_type
->
has_title
)
{
$new_type
->
title_label
=
''
;
}
if
(
!
$new_type
->
has_body
)
{
$new_type
->
body_label
=
''
;
}
$new_type
->
orig_type
=
isset
(
$info
[
'type'
])
?
$info
[
'type'
]
:
''
;
return
$new_type
;
...
...
modules/node/node.test
View file @
a2d62970
...
...
@@ -1087,39 +1087,33 @@ class NodeTypeTestCase extends DrupalWebTestCase {
$this
->
assertRaw
(
'Title'
,
t
(
'Title field was found.'
));
$this
->
assertRaw
(
'Body'
,
t
(
'Body field was found.'
));
// Rename the title
field and remove the body
field.
// Rename the title field.
$edit
=
array
(
'title_label'
=>
'Foo'
,
'body_label'
=>
''
,
);
$this
->
drupalPost
(
'admin/structure/types/manage/page'
,
$edit
,
t
(
'Save content type'
));
// Refresh the field information for the rest of the test.
field_info_cache_clear
();
$this
->
assertFalse
(
field_info_instance
(
'node'
,
'body'
,
'page'
),
t
(
'Body field was removed.'
));
$this
->
drupalGet
(
'node/add/page'
);
$this
->
assertRaw
(
'Foo'
,
t
(
'New title label was displayed.'
));
$this
->
assertNoRaw
(
'Title'
,
t
(
'Old title label was not displayed.'
));
$this
->
assertNoRaw
(
'Full text'
,
t
(
'Body field was not found.'
));
//
Add the body field again and c
hange the name, machine name and description.
//
C
hange the name, machine name and description.
$edit
=
array
(
'name'
=>
'Bar'
,
'type'
=>
'bar'
,
'description'
=>
'Lorem ipsum.'
,
'body_label'
=>
'Baz'
,
);
$this
->
drupalPost
(
'admin/structure/types/manage/page'
,
$edit
,
t
(
'Save content type'
));
field_info_cache_clear
();
$instance
=
field_info_instance
(
'node'
,
'body'
,
'bar'
);
$this
->
assertEqual
(
$instance
[
'label'
],
'Baz'
,
t
(
'Body field was added.'
));
$this
->
drupalGet
(
'node/add'
);
$this
->
assertRaw
(
'Bar'
,
t
(
'New name was displayed.'
));
$this
->
assertRaw
(
'Lorem ipsum'
,
t
(
'New description was displayed.'
));
$this
->
clickLink
(
'Bar'
);
$this
->
assertEqual
(
url
(
'node/add/bar'
,
array
(
'absolute'
=>
TRUE
)),
$this
->
getUrl
(),
t
(
'New machine name was used in URL.'
));
$this
->
assertRaw
(
'Foo'
,
t
(
'Title field was found.'
));
$this
->
assertRaw
(
'B
az
'
,
t
(
'Body field was found.'
));
$this
->
assertRaw
(
'B
ody
'
,
t
(
'Body field was found.'
));
}
}
...
...
modules/simpletest/drupal_web_test_case.php
View file @
a2d62970
...
...
@@ -842,6 +842,7 @@ protected function drupalCreateContentType($settings = array()) {
$saved_type
=
node_type_save
(
$type
);
node_types_rebuild
();
menu_rebuild
();
node_add_body_field
(
$type
);
$this
->
assertEqual
(
$saved_type
,
SAVED_NEW
,
t
(
'Created content type %type.'
,
array
(
'%type'
=>
$type
->
type
)));
...
...
modules/user/user.install
View file @
a2d62970
...
...
@@ -483,7 +483,7 @@ function user_update_7004(&$sandbox) {
'type'
=>
'int'
,
'not null'
=>
TRUE
,
'default'
=>
0
,
'description'
=>
t
(
"Foreign key:
{
file_managed
}
.fid of user's picture."
)
,
'description'
=>
"Foreign key:
{
file_managed
}
.fid of user's picture."
,
);
if
(
!
isset
(
$sandbox
[
'progress'
]))
{
...
...
profiles/standard/standard.install
View file @
a2d62970
...
...
@@ -227,6 +227,7 @@ function standard_install() {
foreach
(
$types
as
$type
)
{
$type
=
node_type_set_defaults
(
$type
);
node_type_save
(
$type
);
node_add_body_field
(
$type
);
}
// Insert default pre-defined RDF mapping into the database.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment