Index: cck_redirection.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck_redirection/cck_redirection.module,v retrieving revision 1.1.4.2 diff -u -p -r1.1.4.2 cck_redirection.module --- cck_redirection.module 31 Oct 2008 21:51:55 -0000 1.1.4.2 +++ cck_redirection.module 24 Jun 2009 05:51:30 -0000 @@ -1,607 +1,606 @@ - 'cck_redirection_js', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); - - // Frameset Redirection - $items['redirect'] = array( - 'page callback' => 'cck_redirection_frameset', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); - - // Header page in frameset redirection - $items['cck_redirection/header'] = array( - 'page callback' => 'cck_redirection_frameset_header', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); - return $items; -} - -/** - * Implementation of hook_theme(). - */ -function cck_redirection_theme() { + 'cck_redirection_js', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + + // Frameset Redirection + $items['redirect'] = array( + 'page callback' => 'cck_redirection_frameset', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + + // Header page in frameset redirection + $items['cck_redirection/header'] = array( + 'page callback' => 'cck_redirection_frameset_header', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + return $items; +} + +/** + * Implementation of hook_theme(). + */ +function cck_redirection_theme() { return array( 'cck_redirection' => array( 'arguments' => array('element' => NULL), - ), - 'cck_redirection_frameset' => array( // Show the new page in the bottom half of a frameset (think Google Images) - 'template' => 'cck-redirection-frameset', - 'arguments' => array('uri' => NULL, 'element' => NULL), - ), - 'cck_redirection_frameset_header' => array( // Theme the header on a frameset - 'template' => 'cck-redirection-frameset-header', - ), - 'cck_redirection_delay_msg' => array( // Themes a JS Delay message (i.e. "This node will redirect to ___ in five seconds...") - 'arguments' => array('element' => NULL) - ), - 'cck_redirection_formatter_default' => array( // Suppress - 'arguments' => array('element' => NULL), - ), - 'cck_redirection_formatter_link' => array( // Show as link - 'arguments' => array('element' => NULL), - ), - 'cck_redirection_formatter_plain' => array( // Show as plain text - 'arguments' => array('element' => NULL), - ), - ); -} - -/** - * Implementation of hook_perm(). - */ -function cck_redirection_perm() { - return array('bypass redirection'); -} - -/** - * Implementation of hook_nodeapi(). - */ -function cck_redirection_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { - if ($op == 'view') { - $GLOBALS['cck_redirection_teaser'] = $a3; - $GLOBALS['cck_redirection_page'] = $a4; - } -} - -/** - * Implementation of hook_form_alter(). - * - * This hook is used to add custom validation to the addition of new or - * existing fields to a node type. This is to make sure that a user - * does not add two or more cck_redirection fields to a given node type. - * While this does not present any inherent danger, this should be - * prevented because the cck_redirection field module will only look at - * one cck_redirection field anyway. After all, we will never have the - * opportunity to redirect the same user to two different sites - * at the same time in the same browser window. - */ -function cck_redirection_form_alter(&$form, $form_state, $form_id) { - if ($form_id == 'content_admin_field_main') { - $form['#validate'][] = 'cck_redirection_content_admin_field_main_validate'; - } - - // We don't want the user to be able to have this field work with multiple values, so we will - // hide this option from the admin when he is configuring the field. - if ($form_id == '_content_admin_field' && $form['main']['type']['#value'] == 'cck_redirection') { - $form['field']['multiple']['#type'] = 'hidden'; - $form['field']['multiple']['#value'] = $form['field']['multiple']['#default_value']; - } -} - -/********************************************************************* - * FAPI Hooks - */ - -/** - * Implementation of FAPI hook_elements(). - */ + ), + 'cck_redirection_frameset' => array( // Show the new page in the bottom half of a frameset (think Google Images) + 'template' => 'cck-redirection-frameset', + 'arguments' => array('uri' => NULL, 'element' => NULL), + ), + 'cck_redirection_frameset_header' => array( // Theme the header on a frameset + 'template' => 'cck-redirection-frameset-header', + ), + 'cck_redirection_delay_msg' => array( // Themes a JS Delay message (i.e. "This node will redirect to ___ in five seconds...") + 'arguments' => array('element' => NULL) + ), + 'cck_redirection_formatter_default' => array( // Suppress + 'arguments' => array('element' => NULL), + ), + 'cck_redirection_formatter_link' => array( // Show as link + 'arguments' => array('element' => NULL), + ), + 'cck_redirection_formatter_plain' => array( // Show as plain text + 'arguments' => array('element' => NULL), + ), + ); +} + +/** + * Implementation of hook_perm(). + */ +function cck_redirection_perm() { + return array('bypass redirection'); +} + +/** + * Implementation of hook_nodeapi(). + */ +function cck_redirection_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { + if ($op == 'view') { + $GLOBALS['cck_redirection_teaser'] = $a3; + $GLOBALS['cck_redirection_page'] = $a4; + } +} + +/** + * Implementation of hook_form_alter(). + * + * This hook is used to add custom validation to the addition of new or + * existing fields to a node type. This is to make sure that a user + * does not add two or more cck_redirection fields to a given node type. + * While this does not present any inherent danger, this should be + * prevented because the cck_redirection field module will only look at + * one cck_redirection field anyway. After all, we will never have the + * opportunity to redirect the same user to two different sites + * at the same time in the same browser window. + */ +function cck_redirection_form_alter(&$form, $form_state, $form_id) { + if ($form_id == 'content_admin_field_main') { + $form['#validate'][] = 'cck_redirection_content_admin_field_main_validate'; + } + + // We don't want the user to be able to have this field work with multiple values, so we will + // hide this option from the admin when he is configuring the field. + if ($form_id == '_content_admin_field' && $form['main']['type']['#value'] == 'cck_redirection') { + $form['field']['multiple']['#type'] = 'hidden'; + $form['field']['multiple']['#value'] = $form['field']['multiple']['#default_value']; + } +} + +/********************************************************************* + * FAPI Hooks + */ + +/** + * Implementation of FAPI hook_elements(). + */ function cck_redirection_elements() { return array( 'cck_redirection' => array( '#input' => TRUE, - '#columns' => array('value'), + '#columns' => array('value'), '#delta' => 0, '#process' => array('cck_redirection_process'), '#autocomplete_path' => FALSE, ), - ); - -} - -/********************************************************************* - * CCK Hooks: Fields - */ - -/** - * Implementation of hook_field_info(). - */ -function cck_redirection_field_info() { - return array( - 'cck_redirection' => array( - 'label' => 'Redirection', - 'description' => t('Store a URI in the database (up to 255 characters).'), - ), - ); -} - -/** - * Implementation of hook_field_settings(). - */ -function cck_redirection_field_settings($op, $field) { - switch ($op) { - case 'form': - return array(); - case 'validate': - break; - case 'save': - return array(); - case 'database columns': - $columns = array( - 'value' => array( - 'type' => 'varchar', - 'length' => 255, - 'not null' => FALSE, - 'sortable' => TRUE, - 'default value' => NULL, - ), - ); - return $columns; - case 'filters': - return array(); - } -} - -/** - * Implementation of hook_field(). - */ -function cck_redirection_field($op, &$node, $field, &$items, $teaser, $page) { - switch ($op) { - case 'validate': - // TODO: Do URI validation here. - break; - } -} - -/********************************************************************* - * CCK Hooks: Field Formatters - */ - -/** - * Implementation of hook_field_formatter_info(). - */ -function cck_redirection_field_formatter_info() { - return array( - 'default' => array( - 'label' => t('Suppress'), - 'field types' => array('cck_redirection'), - ), - 'link' => array( - 'label' => t('Show as Link'), - 'field types' => array('cck_redirection'), - ), - 'plain' => array( - 'label' => t('Show as Plain Text'), - 'field types' => array('cck_redirection'), - ), - ); -} - -/********************************************************************* - * CCK Hooks: Widgets - */ - -/** - * Implementation of hook_widget_info(). - */ -function cck_redirection_widget_info() { - return array( - 'cck_redirection' => array( - 'label' => 'Text field', - 'field types' => array('cck_redirection'), - 'multiple values' => CONTENT_HANDLE_CORE, - 'callbacks' => array( - 'default value' => CONTENT_CALLBACK_DEFAULT, - ), - ), - ); -} - -/** - * Implementation of hook_widget_settings(). - */ -function cck_redirection_widget_settings($op, $widget) { - switch ($op) { - case 'form': - $form = array(); - - $description = NULL; - $description .= t('Select the manner in which redirection should take place. Options are:') . '