Commit 78b447ea authored by JonBob's avatar JonBob

#69472: Change type prefix from "content-" to "content_" to assist in theming

of forms. Those using views.module may have to re-save views after this change.
Custom node templates will need to be renamed.
parent 392fc8b1
......@@ -184,3 +184,41 @@ function content_update_5() {
function content_update_6() {
return array(update_sql('DELETE FROM {cache}'));
}
/**
* Rename the "content-" prefix to "content_" to aid in form theming.
*/
function content_update_7() {
$ret = array();
$type_result = db_query("SELECT type_name FROM {node_type} WHERE type_name LIKE 'content-%%'");
if (db_num_rows($type_result)) {
// Multi-part update
if (!isset($_SESSION['content_update_7'])) {
$_SESSION['content_update_7'] = 0;
$_SESSION['content_update_7_max'] = db_num_rows($type_result);
}
$type = db_fetch_object($type_result);
$old_type_name = $type->type_name;
$new_type_name = str_replace('content-', 'content_', $old_type_name);
$ret[] = update_sql("UPDATE {node} SET type = '". $new_type_name ."' WHERE type = '". $old_type_name ."'");
$ret[] = update_sql("UPDATE {node_type} SET type_name = '". $new_type_name ."' WHERE type_name = '". $old_type_name ."'");
$ret[] = update_sql("UPDATE {node_field_instance} SET type_name = '". $new_type_name ."' WHERE type_name = '". $old_type_name ."'");
$ret[] = update_sql("UPDATE {vocabulary_node_types} SET type = '". $new_type_name ."' WHERE type = '". $old_type_name ."'");
$variable_result = db_query("SELECT name, value FROM {variable} WHERE name LIKE '%%%s%%' OR value LIKE '%%%s%%'", $old_type_name, $old_type_name);
while ($variable = db_fetch_object($variable_result)) {
$new_name = str_replace($old_type_name, $new_type_name, $variable->name);
$new_value = str_replace($old_type_name, $new_type_name, $variable->value);
db_query("UPDATE {variable} SET name = '%s', value = '%s' WHERE name = '%s'", $new_name, $new_value, $variable->name);
}
$ret[] = update_sql('DELETE FROM {cache}');
$_SESSION['content_update_7']++;
$ret['#finished'] = $_SESSION['content_update_7'] / $_SESSION['content_update_7_max'];
return $ret;
}
}
......@@ -723,7 +723,7 @@ function _content_type_info($reset = FALSE) {
$info['content types'][$type['type_name']] = $type;
}
dprint_r($info);
cache_set('content_type_info', serialize($info), CACHE_PERMANENT);
}
}
......@@ -769,7 +769,7 @@ function content_database_info($field) {
$db_info['table'] = 'node_data_'. $field['field_name'];
}
else {
$db_info['table'] = 'node_'. strtr($field['type_name'], '-', '_');
$db_info['table'] = 'node_'. $field['type_name'];
}
if (is_array($columns) && count($columns)) {
......@@ -1032,6 +1032,15 @@ function content_pathauto_node($op, $node = NULL) {
case 'values':
$results = array();
// Get node output (filtered and with module-specific fields).
if (node_hook($node, 'view')) {
node_invoke($node, 'view', false, false);
}
else {
$node = node_prepare($node, false);
}
// Allow modules to change $node->body before viewing.
node_invoke_nodeapi($node, 'view', false, false);
// Get node output (filtered and with module-specific fields).
if (node_hook($node, 'view')) {
node_invoke($node, 'view', false, false);
......@@ -1044,7 +1053,7 @@ function content_pathauto_node($op, $node = NULL) {
foreach (content_fields() as $field) {
$items = $node->$field['field_name'];
$results['['. $field['field_name'] .']'] = pathauto_cleanstring($items[0]['view']);
$results['['. $field['field_name'] .']'] = pathauto_cleanstring(strip_tags($items[0]['view']));
}
return $results;
......
......@@ -139,7 +139,7 @@ function _content_admin_type_edit_submit($form_id, $form_values) {
$form_values['type_name'] = drupal_strtolower($form_values['type_name']);
$form_values['type_name'] = str_replace(array(' ', '-'), '_', $form_values['type_name']);
$form_values['type_name'] = preg_replace('/[^a-z0-9_]/', '', $form_values['type_name']);
$form_values['type_name'] = 'content-'. $form_values['type_name'];
$form_values['type_name'] = 'content_'. $form_values['type_name'];
$form_values['type_name'] = substr($form_values['type_name'], 0, 32);
if (isset($types[$form_values['type_name']])) {
$counter = 0;
......@@ -154,7 +154,7 @@ function _content_admin_type_edit_submit($form_id, $form_values) {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {node_". strtr($form_values['type_name'], '-', '_') ."} (
db_query("CREATE TABLE {node_". $form_values['type_name'] ."} (
vid int unsigned NOT NULL default '0',
nid int unsigned NOT NULL default '0',
PRIMARY KEY (vid)
......@@ -162,7 +162,7 @@ function _content_admin_type_edit_submit($form_id, $form_values) {
break;
case 'pgsql':
db_query("CREATE TABLE {node_". strtr($form_values['type_name'], '-', '_') ."} (
db_query("CREATE TABLE {node_". $form_values['type_name'] ."} (
vid integer unsigned NOT NULL default '0',
nid integer unsigned NOT NULL default '0',
PRIMARY KEY (vid)
......@@ -213,7 +213,7 @@ function _content_admin_type_delete_submit($form_id, $form_values) {
db_query("DELETE FROM {node_field_instance} WHERE type_name = '%s'", $form_values['type_name']);
db_query("DELETE FROM {node_type} WHERE type_name = '%s'", $form_values['type_name']);
db_query("DROP TABLE {node_". strtr($form_values['type_name'], '-', '_') ."}");
db_query("DROP TABLE {node_". $form_values['type_name'] ."}");
drupal_set_message(t('Deleted content type %type.', array('%type' => theme('placeholder', $type['label']))));
content_clear_type_cache();
......
......@@ -275,7 +275,7 @@ function nodereference_autocomplete($field_name, $string = '') {
foreach (_nodereference_potential_references($field, TRUE) as $key => $value) {
if (stristr($value->title, $string)) {
$matches[$value->title] = check_plain('('. str_replace('content-', '', $value->type) .') '. $value->title);
$matches[$value->title] = check_plain('('. str_replace('content_', '', $value->type) .') '. $value->title);
}
}
......
......@@ -41,8 +41,8 @@ may theme the entire node as a unit. This allows you to affect field order, to
change the HTML structure to something more complicated, like a table, or even
to exclude fields from the presentation entirely. The setup for theming a node
is simpler than for theming a field; simply create a file called
"node-content-foo.tpl.php" where "content-foo" is the content type name as
"node-content_foo.tpl.php" where "content_foo" is the content type name as
listed on the administration page. For an example of the typical contents of
this file, investigate the included example here
("node-content-example.tpl.php") or the "node.tpl.php" file that comes with
("node-content_example.tpl.php") or the "node.tpl.php" file that comes with
your theme.
\ No newline at end of file
......@@ -257,4 +257,3 @@ function _userreference_filter_handler($op, $filterinfo) {
$options = array_merge($options, _userreference_potential_references($filterinfo['extra']['field']));
return $options;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment