Only in node_style_old: node_style.inc
Only in node_style: node_style.inc.old
diff -urp node_style_old/node_style.info node_style/node_style.info
--- node_style_old/node_style.info 2009-04-15 18:06:18.000000000 -0500
+++ node_style/node_style.info 2009-04-15 18:08:29.000000000 -0500
@@ -1,8 +1,10 @@
; $Id: node_style.info,v 1.1 2007/01/16 01:17:29 karthik Exp $
name = Node style
description = Allows for node specific customisations.
-version = "$Name: DRUPAL-5--2-1 $"
+
; Information added by drupal.org packaging script on 2007-04-07
-version = "5.x-2.1"
+version = "6.x-1.x-dev"
project = "node_style"
+
+core = 6.x
diff -urp node_style_old/node_style.install node_style/node_style.install
--- node_style_old/node_style.install 2009-04-15 18:06:18.000000000 -0500
+++ node_style/node_style.install 2009-04-15 18:08:52.000000000 -0500
@@ -2,102 +2,76 @@
// $Id: node_style.install,v 1.8.2.1 2007/04/07 08:45:52 karthik Exp $
/**
- * Implementation of hook_install().
+ * @file
+ * Install for the node_style module
*/
-function node_style_install() {
- $ret = array();
-
- switch ($GLOBALS['db_type']) {
- case 'mysqli':
- case 'mysql':
- db_query("CREATE TABLE {node_style_schemes} (
- sid int(11) unsigned NOT NULL auto_increment,
- name varchar(64) NOT NULL default '',
- variables text NOT NULL,
- PRIMARY KEY (sid))
- COMMENT='Node style module: style scheme settings'
- /*!40100 default CHARACTER SET utf8 */"
- );
- db_query("CREATE TABLE {node_style_maps} (
- nid int(11) unsigned NOT NULL default 0,
- sid int(11) unsigned NOT NULL default 0,
- PRIMARY KEY (nid))
- COMMENT='Node style module: nid to scheme map'
- /*!40100 default CHARACTER SET utf8 */"
- );
- break;
- case 'pgsql':
- db_query("CREATE TABLE {node_style_schemes} (
- sid serial,
- name varchar(64) NOT NULL default '',
- variables text NOT NULL,
- PRIMARY KEY (sid))"
- );
- db_query("CREATE TABLE {node_style_maps} (
- nid integer NOT NULL default 0,
- sid integer NOT NULL default 0,
- PRIMARY KEY (nid))"
- );
- }
+
+/**
+ * Implementation of hook_schema().
+ */
+function node_style_schema() {
+ $schema['node_style_schemes'] = array(
+ 'description' => t('Node style module: style scheme settings'),
+ 'fields' => array(
+ 'sid' => array(
+ 'description' => t('TODO'),
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ ),
+ 'name' => array(
+ 'description' => t('TODO'),
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'variables' => array(
+ 'description' => t('TODO'),
+ 'type' => 'text',
+ 'not null' => TRUE,
+ ),
+ ),
+ 'primary key' => array('sid'),
+ );
+
+ $schema['node_style_maps'] = array(
+ 'description' => t('Node style module: nid to scheme map'),
+ 'fields' => array(
+ 'nid' => array(
+ 'description' => t('TODO'),
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'sid' => array(
+ 'description' => t('TODO'),
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ ),
+ 'primary key' => array('nid'),
+ );
- return $ret;
+ return $schema;
}
-function node_style_update_2() {
- $ret = array();
-
- switch ($GLOBALS['db_type']) {
- case 'mysqli':
- case 'mysql':
- $ret[] = update_sql("CREATE TABLE {node_style_schemes} (
- sid int(11) unsigned NOT NULL auto_increment,
- name varchar(64) NOT NULL default '',
- variables text NOT NULL,
- PRIMARY KEY (sid))
- COMMENT='Node style module: style scheme settings'
- /*!40100 default CHARACTER SET utf8 */"
- );
- $ret[] = update_sql("CREATE TABLE {node_style_maps} (
- nid int(11) unsigned NOT NULL default 0,
- sid int(11) unsigned NOT NULL default 0,
- PRIMARY KEY (nid))
- COMMENT='Node style module: nid to scheme map'
- /*!40100 default CHARACTER SET utf8 */"
- );
- break;
- case 'pgsql':
- $ret[] = update_sql("CREATE TABLE {node_style_schemes} (
- sid serial,
- name varchar(64) NOT NULL default '',
- variables text NOT NULL,
- PRIMARY KEY (sid))"
- );
- $ret[] = update_sql("CREATE TABLE {node_style_maps} (
- nid integer NOT NULL default 0,
- sid integer NOT NULL default 0,
- PRIMARY KEY (nid))"
- );
- break;
- }
-
- $result = db_query("SELECT * FROM {node_style}");
- $sid = 1;
- while ($style = db_fetch_array($result)) {
- $name = 'Scheme '. $sid;
- $ret[] = update_sql("INSERT INTO {node_style_schemes} (sid, name, variables) VALUES ($sid, '$name', '". $style['variables'] ."')");
- $ret[] = update_sql("INSERT INTO {node_style_maps} (nid, sid) VALUES (". $style['nid'] .", $sid)");
- $sid++;
- }
-
- $ret[] = update_sql("DROP TABLE {node_style}");
-
- return $ret;
+/**
+ * Implementation of hook_install().
+ */
+function node_style_install() {
+ drupal_install_schema('node_style');
}
/**
* Implementation of hook_uninstall().
*/
function node_style_uninstall() {
- db_query('DROP TABLE {node_style_maps}, {node_style_schemes}');
+ // Remove tables.
+ drupal_uninstall_schema('node_style');
+
variable_del('node_style_mode');
}
diff -urp node_style_old/node_style.module node_style/node_style.module
--- node_style_old/node_style.module 2009-04-15 18:06:18.000000000 -0500
+++ node_style/node_style.module 2009-04-15 18:09:07.000000000 -0500
@@ -12,11 +12,18 @@
* Make module usable with more than just nodes.
*/
+/* TODO Implement the hook_theme registry. Combine all theme registry entries
+ into one hook_theme function in each corresponding module file.
+function node_style_theme() {
+ return array(
+ );
+} */
+
/**
* Implementation of hook_help().
*/
-function node_style_help($section) {
- switch ($section) {
+function node_style_help($path, $arg) {
+ switch ($path) {
case 'admin/help#node_style':
return t('This module allows for node specific style customisations. Its primary uses include:
@@ -41,90 +48,88 @@ Compatibility mode will be deactivated w
/**
* Implementation of hook_menu().
*/
-function node_style_menu($may_cache) {
- global $node_style;
-
+function node_style_menu() {
$items = array();
-
- if ($may_cache) {
- $items[] = array(
- 'path' => 'admin/build/node_style',
- 'title' => t('Node style'),
- 'callback' => '_node_style_schemes',
- 'access' => user_access('administer node styles')
+
+ $items['admin/build/node_style'] = array(
+ 'title' => 'Node style',
+ 'page callback' => '_node_style_schemes',
+ 'access arguments' => array('administer node styles')
);
- $items[] = array(
- 'path' => 'admin/build/node_style/schemes',
- 'title' => t('Schemes'),
- 'callback' => '_node_style_schemes',
- 'access' => user_access('administer node styles'),
+ $items['admin/build/node_style/schemes'] = array(
+ 'title' => 'Schemes',
+ 'page callback' => '_node_style_schemes',
+ 'access arguments' => array('administer node styles'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1
);
- $items[] = array(
- 'path' => 'admin/build/node_style/add',
- 'title' => t('Add scheme'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('_node_style_schemes_add'),
- 'access' => user_access('administer node styles'),
+ $items['admin/build/node_style/add'] = array(
+ 'title' => 'Add scheme',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('_node_style_schemes_add'),
+ 'access arguments' => array('administer node styles'),
'type' => MENU_LOCAL_TASK
);
- $items[] = array(
- 'path' => 'admin/build/node_style/configure',
- 'title' => t('Configure'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('_node_style_configure'),
- 'access' => user_access('administer node styles'),
+ $items['admin/build/node_style/configure'] = array(
+ 'title' => 'Configure',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('_node_style_configure'),
+ 'access arguments' => array('administer node styles'),
'type' => MENU_LOCAL_TASK
);
- $items[] = array(
- 'path' => 'admin/build/node_style/edit',
- 'title' => t('Edit scheme'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('_node_style_schemes_edit'),
- 'access' => user_access('administer node styles'),
+ $items['admin/build/node_style/edit/%'] = array(
+ 'title' => 'Edit scheme',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('_node_style_edit_scheme', 4),
+ 'access arguments' => array('administer node styles'),
'type' => MENU_CALLBACK
);
- $items[] = array(
- 'path' => 'admin/build/node_style/delete',
- 'title' => t('Delete scheme'),
- 'callback' => 'drupal_get_form',
- 'callback arguments' => array('_node_style_schemes_delete'),
- 'access' => user_access('administer node styles'),
+ $items['admin/build/node_style/delete/%'] = array(
+ 'title' => 'Delete scheme',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('_node_style_schemes_delete', 4),
+ 'access arguments' => array('administer node styles'),
'type' => MENU_CALLBACK
);
- }
- else {
- // node_style configurations need to be loaded in hook_menu to allow for
- // cached pages. Workarounds for the global are welcome.
+
+ return $items;
+}
+
+/**
+ * Implementation of hook_init().
+ */
+function node_style_init() {
+
+global $_node_style;
+
+// node_style configurations need to be loaded in hook_init to allow for
+// cached pages. Workarounds for the global are welcome.
+
if (arg(0) == 'node') {
if (is_numeric(arg(1)) && empty($_POST)) {
- $node_style = _node_style_get_node_style(arg(1));
- _node_style_set_custom_theme($node_style);
+ $_node_style = _node_style_get_node_style(arg(1));
+ _node_style_set_custom_theme($_node_style);
}
elseif (!empty($_POST) && (arg(1) == 'add' || arg(2) == 'edit') && isset($_POST['op']) && $_POST['op'] == 'Preview' && isset($_POST['node_style_scheme'])) {
- // Since this is a node form preview, initialise $node_style to ensure
+ // Since this is a node form preview, initialise $_node_style to ensure
// that previews work properly for existing nodes that are being edited.
- $node_style = array();
+ $_node_style = array();
// Hack: Access $_POST to retrieve the node_style scheme. Due to the
// fact that $custom_theme cannot be set in hook_nodeapi, this is the
// only workable solution for allowing node_style previews.
// If the situation arises where theme overrides have become more
// flexible, this block can be shoved into hook_nodeapi.
- $node_style = _node_style_get_scheme((int) $_POST['node_style_scheme']);
+ $_node_style = _node_style_get_scheme((int) $_POST['node_style_scheme']);
// Set custom theme if enabled.
- _node_style_set_custom_theme($node_style);
+ _node_style_set_custom_theme($_node_style);
}
}
// node_style.inc includes the _phptemplate_variables call. This function
// has been isolated as possibilities exist where the same function might be
// declared elsewhere.
- if (variable_get('node_style_mode', 0) && (arg(2) != 'node_style')) {
- include 'node_style.inc';
- }
- }
-
- return $items;
+ /* if (variable_get('node_style_mode', 0) && (arg(2) != 'node_style')) {
+ module_load_include('inc', 'node_style', 'ode_style');
+ } */
}
/**
@@ -137,7 +142,7 @@ function node_style_perm() {
/**
* Implementation of hook_form_alter().
*/
-function node_style_form_alter($form_id, &$form) {
+function node_style_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && user_access('customise node styles')) {
$node = $form['#node'];
@@ -161,14 +166,14 @@ function node_style_form_alter($form_id,
elseif ($form_id == 'system_themes') {
// To disable theme compatibility mode when changes are made to the theme
// screen, inject a submit handler.
- $form['#submit']['node_style_alter_mode_submit'] = array();
+ $form['#submit'][] = 'node_style_alter_mode_submit';
}
}
/**
* Process system_theme function submissions.
*/
-function node_style_alter_mode_submit($form_id, $form_values) {
+function node_style_alter_mode_submit($form, &$form_state) {
// Delete compatibility variable.
variable_del('node_style_mode');
// Point user to the configuration screen.
@@ -236,26 +241,28 @@ function _node_style_configure() {
/**
* Process the theme compatibility configuration form.
*/
-function _node_style_configure_submit($form_id, $form_values) {
- variable_set('node_style_mode', $form_values['mode']);
+function _node_style_configure_submit($form, &$form_state) {
+ variable_set('node_style_mode', $form_state['values']['mode']);
drupal_set_message(t('Configuration saved.'));
-
- return 'admin/build/node_style';
+
+ $form_state['redirect'] = 'admin/build/node_style';
+ $form_state['node_style_mode'] = $form_state['values']['mode'];
}
-/**
+/**f
* Menu callback: Add a new scheme.
*/
-function _node_style_schemes_add($sid = NULL) {
+function _node_style_schemes_add(&$form_state, $sid = NULL) {
$hide_array = _node_style_get_arrays();
-
- if (isset($sid)) {
+ if (isset($sid)) {
$scheme = _node_style_get_scheme($sid);
- if (isset($scheme)) {
+ if (isset($scheme)) {
$form['sid'] = array('#type' => 'value', '#value' => $sid);
}
}
+
+
$form['name'] = array(
'#type' => 'textfield',
@@ -316,7 +323,7 @@ function _node_style_schemes_add($sid =
);
$form['submit'] = array('#type' => 'submit', '#value' => t('Save scheme'));
- $form['#base'] = 'node_style_scheme';
+ $form['#submit'][] = 'node_style_scheme_submit';
return $form;
}
@@ -324,9 +331,9 @@ function _node_style_schemes_add($sid =
/**
* Menu callback: Edit a scheme.
*/
-function _node_style_schemes_edit($sid = NULL) {
+function _node_style_edit_scheme(&$form_state, $sid = NULL) {
if (isset($sid)) {
- return _node_style_schemes_add($sid);
+ return _node_style_schemes_add(&$form_state, $sid);
}
else {
drupal_set_message(t('Scheme not found.'), 'error');
@@ -337,34 +344,35 @@ function _node_style_schemes_edit($sid =
/**
* Process a scheme add / edit form submission.
*/
-function node_style_scheme_submit($form_id, $form_values) {
+function node_style_scheme_submit($form, &$form_state) {
$scheme = array('display' => array(), 'misc' => array());
- $scheme['display']['node'] = array_filter($form_values['display']['node']);
+ $scheme['display']['node'] = array_filter($form_state['values']['display']['node']);
$scheme['display']['node'] = array_keys($scheme['display']['node']);
- $scheme['display']['page'] = array_filter($form_values['display']['page']);
+ $scheme['display']['page'] = array_filter($form_state['values']['display']['page']);
$scheme['display']['page'] = array_keys($scheme['display']['page']);
- $scheme['misc']['theme'] = $form_values['misc']['theme'];
- $scheme['misc']['head'] = $form_values['misc']['head'];
+ $scheme['misc']['theme'] = $form_state['values']['misc']['theme'];
+ $scheme['misc']['head'] = $form_state['values']['misc']['head'];
- if (isset($form_values['sid'])) {
- _node_style_update_scheme($form_values['sid'], $form_values['name'], $scheme);
+ if (isset($form_state['values']['sid'])) {
+ _node_style_update_scheme($form_state['values']['sid'], $form_state['values']['name'], $scheme);
drupal_set_message(t('Style scheme %name updated successfully.', array('%name' => $name)));
}
else {
- _node_style_add_scheme($form_values['name'], $scheme);
+ _node_style_add_scheme($form_state['values']['name'], $scheme);
drupal_set_message(t('Style scheme %name added successfully.', array('%name' => $name)));
}
cache_clear_all();
- return 'admin/build/node_style';
+ $form_state['redirect'] = 'admin/build/node_style';
+ $form_state['scheme'] = $scheme;
}
/**
* Menu callback: Delete a scheme.
*/
-function _node_style_schemes_delete($sid = NULL) {
+function _node_style_schemes_delete(&$form_state, $sid = NULL) {
if (is_numeric($sid)) {
$scheme = _node_style_get_scheme($sid);
$form['sid'] = array('#type' => 'value', '#value' => $sid);
@@ -386,16 +394,17 @@ function _node_style_schemes_delete($sid
/**
* Process a scheme deletion form submission.
*/
-function _node_style_schemes_delete_submit($form_id, $form_values) {
- db_query("DELETE FROM {node_style_maps} WHERE sid = %d", $form_values['sid']);
- db_query("DELETE FROM {node_style_schemes} WHERE sid = %d", $form_values['sid']);
+function _node_style_schemes_delete_submit($form, &$form_state) {
+ db_query("DELETE FROM {node_style_maps} WHERE sid = %d", $form_state['values']['sid']);
+ db_query("DELETE FROM {node_style_schemes} WHERE sid = %d", $form_state['values']['sid']);
- drupal_set_message(t('The scheme %title has been deleted.', array('%title' => $form_values['scheme_name'])));
- watchdog('content', t('The scheme %title has been deleted.', array('%title' => $form_values['scheme_name'])));
+ drupal_set_message(t('The scheme %title has been deleted.', array('%title' => $form_state['values']['scheme_name'])));
+ watchdog('content', 'The scheme %title has been deleted.', array('%title' => $form_state['values']['scheme_name']));
cache_clear_all();
- return 'admin/build/node_style';
+ $form_state['redirect'] = 'admin/build/node_style';
+ $form_state['scheme_name'] = $form_state['values']['scheme_name'];
}
/**
@@ -404,17 +413,17 @@ function _node_style_schemes_delete_subm
* @see _phptemplate_variables
*/
function node_style_return_vars($hook, $variables) {
- global $node_style;
+ global $_node_style;
- if (!empty($node_style)) {
- $scheme = $node_style['variables'];
+ if (!empty($_node_style)) {
+ $scheme = $_node_style['variables'];
if (isset($scheme['display'][$hook])) {
foreach ($scheme['display'][$hook] as $var) {
// Only affect existing variables.
if (isset($variables[$var])) {
// Set to null rather than '' or array() to ensure that no data type
// mismatches occur.
- $variables[$var] = null;
+ $variables[$var] = NULL;
}
}
}
@@ -422,7 +431,7 @@ function node_style_return_vars($hook, $
// Rather than appending to "head", append to styles, thereby allowing for
// overrides of existing stylesheets.
$variables['styles'] .= trim($scheme['misc']['head']);
- _node_style_set_custom_theme($node_style);
+ _node_style_set_custom_theme($_node_style);
}
}
@@ -447,18 +456,18 @@ function _node_style_delete_node_style($
* Retrieve any node_style settings for a node from the database.
*/
function _node_style_get_node_style($nid) {
- static $node_style = NULL;
+ static $_node_style = NULL;
- if (!isset($node_style)) {
- $node_style = array();
+ if (!isset($_node_style)) {
+ $_node_style = array();
$result = db_query("SELECT m.sid, s.variables FROM {node_style_maps} m LEFT JOIN {node_style_schemes} s USING (sid) WHERE m.nid = %d", $nid);
- if ($node_style = db_fetch_array($result)) {
- $node_style['variables'] = unserialize($node_style['variables']);
+ if ($_node_style = db_fetch_array($result)) {
+ $_node_style['variables'] = unserialize($_node_style['variables']);
}
}
- return $node_style;
+ return $_node_style;
}
/**
@@ -483,7 +492,6 @@ function _node_style_get_scheme($sid) {
if ($scheme = db_fetch_array($result)) {
$scheme['variables'] = unserialize($scheme['variables']);
}
-
return $scheme;
}
@@ -535,12 +543,12 @@ function _node_style_get_arrays() {
/**
* Check the node style and override the theme if necessary.
*/
-function _node_style_set_custom_theme($node_style) {
+function _node_style_set_custom_theme($_node_style) {
global $custom_theme;
- if (isset($node_style['variables']['misc']['theme']) && $node_style['variables']['misc']['theme'] != 'default') {
+ if (isset($_node_style['variables']['misc']['theme']) && $_node_style['variables']['misc']['theme'] != 'default') {
// The current theme is overridden regardless of whether the theme is active
// or not. This is a matter for core to deal with, not this module.
- $custom_theme = $node_style['variables']['misc']['theme'];
+ $custom_theme = $_node_style['variables']['misc']['theme'];
}
}
Only in node_style_old: po
diff -urp node_style_old/README.txt node_style/README.txt
--- node_style_old/README.txt 2009-04-15 18:06:18.000000000 -0500
+++ node_style/README.txt 2009-04-15 18:09:16.000000000 -0500
@@ -40,4 +40,4 @@ Links
Authors
-------
-Karthik Kumar/ Zen / |gatsby| : http://drupal.org/user/21209
\ No newline at end of file
+Karthik Kumar/ Zen / |gatsby| : http://drupal.org/user/21209
Only in node_style: translations