Index: page_title.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/page_title/page_title.module,v
retrieving revision 1.18.2.2
diff -u -p -r1.18.2.2 page_title.module
--- page_title.module 25 Sep 2008 15:48:03 -0000 1.18.2.2
+++ page_title.module 25 Sep 2008 22:37:08 -0000
@@ -79,6 +79,23 @@ function page_title_menu() {
'access arguments' => array('administer page titles'),
'type' => MENU_LOCAL_TASK,
);
+ $items['admin/content/page_title/url'] = array(
+ 'title' => 'Per URL Settings',
+ 'description' => 'Control the display of the Page title based on a per-URL basis.',
+ 'page callback' => 'page_title_admin_url',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer page titles'),
+ 'type' => MENU_LOCAL_TASK,
+ );
+ $items['admin/content/page_title/url/delete'] = array(
+ 'title' => 'Confirm Delete',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('page_title_admin_url_delete'),
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer page titles'),
+ 'type' => MENU_CALLBACK,
+ );
+
return $items;
}
@@ -157,6 +174,159 @@ function page_title_admin_types() {
}
+function page_title_admin_url($id = NULL) {
+ $settings = variable_get('page_title_url', array());
+
+ if (!is_null($id)) {
+ if (!isset($settings[$id])) {
+ echo drupal_not_found();
+ exit;
+ }
+ }
+
+ $rows = array();
+ foreach ($settings as $key => $conf) {
+ $ops = l(t('edit'), 'admin/content/page_title/url/'. $key) .' | ';
+ $ops .= l(t('delete'), 'admin/content/page_title/url/delete/'. $key);
+
+ $rows[] = array(
+ check_plain($conf['path']),
+ check_plain($conf['pattern']),
+ check_plain($conf['scope']),
+ $ops
+ );
+ }
+ $headers = array(
+ t('Path'),
+ t('Page Title Pattern'),
+ t('Scope'),
+ t('Actions'),
+ );
+
+ $output = theme('table', $headers, $rows);
+
+ $output .= drupal_get_form('page_title_admin_url_form', $id);
+
+ return $output;
+}
+
+
+function page_title_admin_url_form($form_state, $id = NULL) {
+ $form = array();
+
+ $settings = variable_get('page_title_url', array());
+
+ $form['page_title_url'] = array(
+ '#type' => 'fieldset',
+ '#title' => isset($id) ? t('Edit Path Pattern') : t('Add Path Pattern'),
+ '#tree' => TRUE,
+ '#collapsible' => !isset($id),
+ '#collapsed' => !isset($id),
+ );
+
+ $form['page_title_url']['path'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Path'),
+ '#description' => t('Enter the source path you want to path page title patterns to, for example taxonomy/term/%'),
+ '#size' => 20,
+ '#maxlength' => 100,
+ '#required' => TRUE,
+ '#default_value' => isset($settings[$id]['path']) ? $settings[$id]['path'] : '',
+ );
+
+ $form['page_title_url']['pattern'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pattern'),
+ '#description' => t('Enter the token pattern you would like to use for this path, for example Category: [term]'),
+ '#size' => 30,
+ '#maxlength' => 100,
+ '#required' => TRUE,
+ '#default_value' => isset($settings[$id]['pattern']) ? $settings[$id]['pattern'] : '',
+ );
+
+ $tokens = token_get_list();
+ $scopes = array_flip(array_keys($tokens));
+
+ foreach ($scopes as $k => $v) {
+ $scopes[$k] = ucwords($k);
+ }
+
+ $form['page_title_url']['scope'] = array(
+ '#type' => 'select',
+ '#title' => t('Scope'),
+ '#description' => t('Select the Scope of the pattern. This defines which tokens are available, for example in Comment scope there are no user tokens; only comment and global would be available.'),
+ '#options' => $scopes,
+ '#default_value' => isset($settings[$id]['scope']) ? $settings[$id]['scope'] : 'global',
+ );
+
+ if (isset($id)) {
+ $form['page_title_url']['actions'] = array('#prefix' => '