trackback_ui.module 6.x-1.x head
<?php
// $Id: trackback_ui.module,v 1.0 2008/04/11 0829 Exp $
/**
* Implementation of hook_form_alter().
*/
function trackback_ui_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'trackback_configure':
$form['trackback_ui_nospam'] = array(
'#type' => 'fieldset',
'#title' => t('Trackback nospam settings'),
'#description' => t('Note: This setting is only used in the case of the automatic detection is disabled.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['trackback_ui_nospam']['trackback_ui_autodetect'] = array(
'#type' => 'checkbox',
'#title' => t('Trackback Auto-Discovery un-output'),
'#description' => t('If checked, rdf code for Trackback Auto-Discovery is not output.'),
'#default_value' => variable_get('trackback_ui_autodetect', 0),
);
$form['trackback_ui_nospam']['trackback_ui_nospamword'] = array(
'#type' => 'textfield',
'#title' => t('Nospam word'),
'#default_value' => variable_get('trackback_ui_nospamword', 'nospam'),
'#description' => t('Define the no-spam word for sufix of the trackback URL. If blank, not used.'),
'#required' => FALSE,
);
$form['trackback_ui_interface'] = array(
'#type' => 'fieldset',
'#title' => t('Trackback user interface settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['trackback_ui_interface']['trackback_ui_oneclick'] = array(
'#type' => 'radios',
'#title' => t('URL one click selection'),
'#default_value' => variable_get('trackback_ui_oneclick', 0),
'#options' => array(
0 => t('Disable'),
1 => t('Enable')
),
'#description' => t('If checked, allow one-click select of trackback URL.'),
);
// Move submit buttons to bottom
$form['buttons']['#weight'] = 1;
break;
}
}
/**
* Implementation of hook_nodeapi().
*/
function trackback_ui_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
case 'view':
if (isset($node->can_receive) && empty($node->in_preview)) {
if ($node->can_receive) {
if (variable_get('trackback_auto_detection_enabled', 0) == 0 && variable_get('trackback_ui_autodetect', 0) == 1) {
unset($node->content['trackback']['autodetect']);
}
if (!$teaser) {
$tb_url = url('trackback/'. $node->nid, array('absolute' => TRUE));
$tb_nospam_word = variable_get('trackback_ui_nospamword', 'nospam');
if (variable_get('trackback_auto_detection_enabled', 0) == 0 && variable_get('trackback_ui_autodetect', 0) == 1 && $tb_nospam_word != '') {
$tb_url = url('trackback/' . $node->nid . '-' . $tb_nospam_word, array('absolute' => TRUE));
}
if (variable_get('trackback_ui_oneclick', 0) == 1) {
$node->content['trackback']['url']['#value'] = theme('trackback_ui_oneclick_url', $tb_url);
}
else {
$node->content['trackback']['url']['#value'] = theme('trackback_ui_url', $tb_url);
}
}
}
}
break;
}
}
/**
* Implementation of hook_theme().
*/
function trackback_ui_theme() {
return array(
'trackback_ui_url' => array(
'arguments' => array('url' => NULL)
),
'trackback_ui_oneclick_url' => array(
'arguments' => array('url' => NULL)
),
);
}
function theme_trackback_ui_url($url) {
drupal_add_css(drupal_get_path('module', 'trackback_ui') . '/trackback_ui.css');
$tb_moderation = variable_get('trackback_moderation', 0);
$tb_nospam_word = variable_get('trackback_ui_nospamword', 'nospam');
if (variable_get('trackback_auto_detection_enabled', 0) == 0 && variable_get('trackback_ui_autodetect', 0) == 1 && $tb_nospam_word != '') {
$tb_url_sufix = TRUE;
}
$output[] = '<div class="tb-url">' . $url . '</div>';
if ($tb_url_sufix || $tb_moderation == 1) {
$output[] = '<div class="tb-message-wrapper">';
if ($tb_url_sufix) {
$output[] = '<div class="tb-message">' . t('Please transmit a trackback with "-%nospam" deleted from the URL.', array('%nospam' => $tb_nospam_word)) . '</div>';
}
if ($tb_moderation == 1) {
$output[] = '<div class="tb-moderation">' . t('Your received trackback is appeared on this page after approved.') . '</div>';
}
$output[] = '</div>';
}
return '<div id="trackback-url">' . theme('box', t('Trackback URL for this post:'), implode("\n", $output)) . '</div>';
}
function theme_trackback_ui_oneclick_url($url) {
drupal_add_css(drupal_get_path('module', 'trackback_ui') . '/trackback_ui.css');
$tb_moderation = variable_get('trackback_moderation', 0);
$tb_nospam_word = variable_get('trackback_ui_nospamword', 'nospam');
if (variable_get('trackback_auto_detection_enabled', 0) == 0 && variable_get('trackback_ui_autodetect', 0) == 1 && $tb_nospam_word != '') {
$tb_url_sufix = TRUE;
}
$output[] = '<div class="tb-url-wrapper">';
$output[] = '<label for="tb-url" class="tb-label">' . t('Trackback URL for this post:') . '</label><br />';
$output[] = '<input type="text" name="tb-url" id="tb-url" class="tb-url" value="' . $url . '" readonly="readonly" onfocus="this.select()" />';
$output[] = '</div>';
if ($tb_url_sufix || $tb_moderation == 1) {
$output[] = '<div class="tb-message-wrapper">';
if ($tb_url_sufix) {
$output[] = '<div class="tb-message">' . t('Please transmit a trackback with "-%nospam" deleted from the URL.', array('%nospam' => $tb_nospam_word)) . '</div>';
}
if ($tb_moderation == 1) {
$output[] = '<div class="tb-moderation">' . t('Your received trackback is appeared on this page after approved.') . '</div>';
}
$output[] = '</div>';
}
return '<div id="trackback-url">' . theme('box', t('Trackbacks'), implode("\n", $output)) . '</div>';
}
// $Id: trackback_ui.module,v 1.0 2008/04/11 0829 Exp $
/**
* Implementation of hook_form_alter().
*/
function trackback_ui_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'trackback_configure':
$form['trackback_ui_nospam'] = array(
'#type' => 'fieldset',
'#title' => t('Trackback nospam settings'),
'#description' => t('Note: This setting is only used in the case of the automatic detection is disabled.'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['trackback_ui_nospam']['trackback_ui_autodetect'] = array(
'#type' => 'checkbox',
'#title' => t('Trackback Auto-Discovery un-output'),
'#description' => t('If checked, rdf code for Trackback Auto-Discovery is not output.'),
'#default_value' => variable_get('trackback_ui_autodetect', 0),
);
$form['trackback_ui_nospam']['trackback_ui_nospamword'] = array(
'#type' => 'textfield',
'#title' => t('Nospam word'),
'#default_value' => variable_get('trackback_ui_nospamword', 'nospam'),
'#description' => t('Define the no-spam word for sufix of the trackback URL. If blank, not used.'),
'#required' => FALSE,
);
$form['trackback_ui_interface'] = array(
'#type' => 'fieldset',
'#title' => t('Trackback user interface settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['trackback_ui_interface']['trackback_ui_oneclick'] = array(
'#type' => 'radios',
'#title' => t('URL one click selection'),
'#default_value' => variable_get('trackback_ui_oneclick', 0),
'#options' => array(
0 => t('Disable'),
1 => t('Enable')
),
'#description' => t('If checked, allow one-click select of trackback URL.'),
);
// Move submit buttons to bottom
$form['buttons']['#weight'] = 1;
break;
}
}
/**
* Implementation of hook_nodeapi().
*/
function trackback_ui_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
case 'view':
if (isset($node->can_receive) && empty($node->in_preview)) {
if ($node->can_receive) {
if (variable_get('trackback_auto_detection_enabled', 0) == 0 && variable_get('trackback_ui_autodetect', 0) == 1) {
unset($node->content['trackback']['autodetect']);
}
if (!$teaser) {
$tb_url = url('trackback/'. $node->nid, array('absolute' => TRUE));
$tb_nospam_word = variable_get('trackback_ui_nospamword', 'nospam');
if (variable_get('trackback_auto_detection_enabled', 0) == 0 && variable_get('trackback_ui_autodetect', 0) == 1 && $tb_nospam_word != '') {
$tb_url = url('trackback/' . $node->nid . '-' . $tb_nospam_word, array('absolute' => TRUE));
}
if (variable_get('trackback_ui_oneclick', 0) == 1) {
$node->content['trackback']['url']['#value'] = theme('trackback_ui_oneclick_url', $tb_url);
}
else {
$node->content['trackback']['url']['#value'] = theme('trackback_ui_url', $tb_url);
}
}
}
}
break;
}
}
/**
* Implementation of hook_theme().
*/
function trackback_ui_theme() {
return array(
'trackback_ui_url' => array(
'arguments' => array('url' => NULL)
),
'trackback_ui_oneclick_url' => array(
'arguments' => array('url' => NULL)
),
);
}
function theme_trackback_ui_url($url) {
drupal_add_css(drupal_get_path('module', 'trackback_ui') . '/trackback_ui.css');
$tb_moderation = variable_get('trackback_moderation', 0);
$tb_nospam_word = variable_get('trackback_ui_nospamword', 'nospam');
if (variable_get('trackback_auto_detection_enabled', 0) == 0 && variable_get('trackback_ui_autodetect', 0) == 1 && $tb_nospam_word != '') {
$tb_url_sufix = TRUE;
}
$output[] = '<div class="tb-url">' . $url . '</div>';
if ($tb_url_sufix || $tb_moderation == 1) {
$output[] = '<div class="tb-message-wrapper">';
if ($tb_url_sufix) {
$output[] = '<div class="tb-message">' . t('Please transmit a trackback with "-%nospam" deleted from the URL.', array('%nospam' => $tb_nospam_word)) . '</div>';
}
if ($tb_moderation == 1) {
$output[] = '<div class="tb-moderation">' . t('Your received trackback is appeared on this page after approved.') . '</div>';
}
$output[] = '</div>';
}
return '<div id="trackback-url">' . theme('box', t('Trackback URL for this post:'), implode("\n", $output)) . '</div>';
}
function theme_trackback_ui_oneclick_url($url) {
drupal_add_css(drupal_get_path('module', 'trackback_ui') . '/trackback_ui.css');
$tb_moderation = variable_get('trackback_moderation', 0);
$tb_nospam_word = variable_get('trackback_ui_nospamword', 'nospam');
if (variable_get('trackback_auto_detection_enabled', 0) == 0 && variable_get('trackback_ui_autodetect', 0) == 1 && $tb_nospam_word != '') {
$tb_url_sufix = TRUE;
}
$output[] = '<div class="tb-url-wrapper">';
$output[] = '<label for="tb-url" class="tb-label">' . t('Trackback URL for this post:') . '</label><br />';
$output[] = '<input type="text" name="tb-url" id="tb-url" class="tb-url" value="' . $url . '" readonly="readonly" onfocus="this.select()" />';
$output[] = '</div>';
if ($tb_url_sufix || $tb_moderation == 1) {
$output[] = '<div class="tb-message-wrapper">';
if ($tb_url_sufix) {
$output[] = '<div class="tb-message">' . t('Please transmit a trackback with "-%nospam" deleted from the URL.', array('%nospam' => $tb_nospam_word)) . '</div>';
}
if ($tb_moderation == 1) {
$output[] = '<div class="tb-moderation">' . t('Your received trackback is appeared on this page after approved.') . '</div>';
}
$output[] = '</div>';
}
return '<div id="trackback-url">' . theme('box', t('Trackbacks'), implode("\n", $output)) . '</div>';
}


最近のコメント
6日 8時間前
6日 8時間前
6日 10時間前
6日 16時間前
6日 19時間前
6日 21時間前
6日 22時間前