diff options
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.install | 117 | ||||
-rw-r--r-- | modules/system/system.module | 3 |
2 files changed, 119 insertions, 1 deletions
diff --git a/modules/system/system.install b/modules/system/system.install index 7ff587f53..c5b165833 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -198,6 +198,24 @@ function system_install() { KEY uid (uid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); + db_query("CREATE TABLE {node_type} ( + type varchar(32) NOT NULL, + name varchar(255) NOT NULL default '', + module varchar(255) NOT NULL, + description mediumtext NOT NULL, + help mediumtext NOT NULL, + has_title tinyint(3) unsigned NOT NULL, + title_label varchar(255) NOT NULL default '', + has_body tinyint(3) unsigned NOT NULL, + body_label varchar(255) NOT NULL default '', + min_word_count smallint(4) unsigned NOT NULL, + custom tinyint(1) NOT NULL DEFAULT '0', + modified tinyint(1) NOT NULL DEFAULT '0', + locked tinyint(1) NOT NULL DEFAULT '0', + orig_type varchar(255) NOT NULL default '', + PRIMARY KEY (type) + ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); + db_query("CREATE TABLE {url_alias} ( pid int(10) unsigned NOT NULL auto_increment, src varchar(128) NOT NULL default '', @@ -789,6 +807,9 @@ function system_install() { db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)"); + db_query("INSERT INTO {node_type} (type, name, module, description, help, has_title, title_label, has_body, body_label, min_word_count, custom, modified, locked, orig_type) VALUES ('page', 'page', 'node', 'If you want to add a static page, like a contact page or an about page, use a page.', '', 1, 'Title', 1, 'Body', 0, 1, 1, 0, 'page')"); + db_query("INSERT INTO {node_type} (type, name, module, description, help, has_title, title_label, has_body, body_label, min_word_count, custom, modified, locked, orig_type) VALUES ('story', 'story', 'node', 'Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extended by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.', '', 1, 'Title', 1, 'Body', 0, 1, 1, 0, 'story')"); + db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('Filtered HTML',',1,2,',1)"); db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code','',0)"); db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('Full HTML','',1)"); @@ -2908,3 +2929,99 @@ function system_update_187() { } return $ret; } + +function system_update_188() { + // Add ability to create dynamic node types like the CCK module + $ret = array(); + + switch ($GLOBALS['db_type']) { + case 'mysqli': + case 'mysql': + // Create node_type table + $ret[] = update_sql("CREATE TABLE {node_type} ( + type varchar(32) NOT NULL, + name varchar(255) NOT NULL, + module varchar(255) NOT NULL, + description mediumtext NOT NULL, + help mediumtext NOT NULL, + has_title tinyint(3) unsigned NOT NULL, + title_label varchar(255) NOT NULL default '', + has_body tinyint(3) unsigned NOT NULL, + body_label varchar(255) NOT NULL default '', + min_word_count smallint(4) unsigned NOT NULL, + custom tinyint(1) NOT NULL DEFAULT '0', + modified tinyint(1) NOT NULL DEFAULT '0', + locked tinyint(1) NOT NULL DEFAULT '0', + orig_type varchar(255) NOT NULL default '', + PRIMARY KEY (type) + ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); + break; + + case 'pgsql': + $ret[] = update_sql("CREATE TABLE {node_type} ( + type varchar(32) NOT NULL, + name varchar(255) NOT NULL, + module varchar(255) NOT NULL, + description text NOT NULL, + help text NOT NULL, + has_title integer unsigned NOT NULL, + title_label varchar(255) NOT NULL default '', + has_body integer unsigned NOT NULL, + body_label varchar(255) NOT NULL default '', + min_word_count integer unsigned NOT NULL, + custom smallint NOT NULL DEFAULT '0', + modified smallint NOT NULL DEFAULT '0', + locked smallint NOT NULL DEFAULT '0', + orig_type varchar(255) NOT NULL default '', + PRIMARY KEY (type) + );"); + break; + } + + // Insert default user-defined node types into the database. + $types = array( + array( + 'type' => 'page', + 'name' => t('page'), + 'module' => 'node', + 'description' => t('If you want to add a static page, like a contact page or an about page, use a page.'), + 'custom' => TRUE, + 'modified' => TRUE, + 'locked' => FALSE, + ), + array( + 'type' => 'story', + 'name' => t('story'), + 'module' => 'node', + 'description' => t('Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extendd by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.'), + 'custom' => TRUE, + 'modified' => TRUE, + 'locked' => FALSE, + ) + ); + + foreach ($types as $type) { + $type = (object) _node_type_set_defaults($type); + node_type_save($type); + } + + cache_clear_all(); + system_modules(); + menu_rebuild(); + node_types_rebuild(); + + // Migrate old values for 'minimum_x_size' variables to the node_type table. + $query = db_query('SELECT type FROM {node_type}'); + while ($result = db_fetch_object($query)) { + $variable_name = 'minimum_'. $result->type .'_size'; + if ($value = db_fetch_object(db_query("SELECT value FROM {variable} WHERE name = '%s'", $variable_name))) { + $value = (int) unserialize($value->value); + db_query("UPDATE {node_type} SET min_word_count = %d, modified = %d WHERE type = '%s'", $value, 1, $result->type); + variable_del($variable_name); + } + } + + node_types_rebuild(); + + return $ret; +} diff --git a/modules/system/system.module b/modules/system/system.module index e19ed56e5..ce2b15767 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1253,6 +1253,7 @@ function system_modules_submit($form_id, $edit) { } menu_rebuild(); + node_types_rebuild(); drupal_set_message(t('The configuration options have been saved.')); return 'admin/settings/modules'; @@ -1377,7 +1378,7 @@ function system_theme_settings($key = '') { ); // Toggle node display. - $node_types = module_invoke('node', 'get_types'); + $node_types = node_get_types('names'); if ($node_types) { $form['node_info'] = array( '#type' => 'fieldset', |