Commit 44a13981 authored by Nicholas Thompson's avatar Nicholas Thompson
Browse files

Work on improving compatibility with Drupal 7

parent 2ef74e0f
<?php
$rows = array();
foreach (element_children($form['title']) as $key) {
$row = array();
$row[] = drupal_render($form['title'][$key]);
$row[] = drupal_render($form['pattern'][$key]);
$rows[] = $row;
}
print theme('table', array('Page Type', 'Pattern'), $rows);
print drupal_render($form);
......@@ -136,7 +136,8 @@ function page_title_admin_settings() {
}
function theme_page_title_admin_settings($form) {
function theme_page_title_admin_settings($variables) {
$form = $variables['form'];
$rows = array();
foreach (element_children($form['patterns']['pattern']) as $key) {
$title = array(
......@@ -144,18 +145,16 @@ function theme_page_title_admin_settings($form) {
'#required' => $form['patterns']['pattern'][$key]['#required'],
);
unset($form['patterns']['pattern'][$key]['#title']);
$row = array(
drupal_render($title),
drupal_render($form['patterns']['scope'][$key]),
drupal_render($form['patterns']['pattern'][$key]),
isset($form['patterns']['showfield'][$key .'_showfield']) ? drupal_render($form['patterns']['showfield'][$key .'_showfield']) : '',
render($title),
render($form['patterns']['scope'][$key]),
render($form['patterns']['pattern'][$key]),
isset($form['patterns']['showfield'][$key .'_showfield']) ? render($form['patterns']['showfield'][$key .'_showfield']) : '',
);
$rows[] = $row;
}
$output = theme('table', array(t('Page Type'), t('Token Scope'), t('Pattern'), t('Show Field')), $rows);
$output = theme('table', array('header' => array(t('Page Type'), t('Token Scope'), t('Pattern'), t('Show Field')), 'rows' => $rows));
$output .= drupal_render_children($form);
return $output;
}
// $Id$
(function ($) {
Drupal.behaviors.pageTitleFieldsetSummaries = {
attach: function (context) {
$('fieldset#edit-page-title', context).setSummary(function (context) {
var pt = $('#edit-page-title-1').val();
var pt = $('input', context).val();
return pt ?
Drupal.t('Page Title: @pt', { '@pt': pt }) :
......
......@@ -13,7 +13,7 @@
/**
* Implementation of hook_help().
* Implement hook_help().
*/
function page_title_help($path, $arg) {
$output = NULL;
......@@ -38,7 +38,7 @@ function page_title_help($path, $arg) {
/**
* Implementation of hook_perm().
* Implement hook_perm().
*/
function page_title_perm() {
return array('set page title', 'administer page titles');
......@@ -46,7 +46,7 @@ function page_title_perm() {
/**
* Implementation of hook_menu().
* Implement hook_menu().
*/
function page_title_menu() {
$items = array();
......@@ -58,6 +58,7 @@ function page_title_menu() {
'page arguments' => array('page_title_admin_settings'),
'access arguments' => array('administer page titles'),
'type' => MENU_LOCAL_TASK,
'file' => 'page_title.admin.inc',
);
return $items;
......@@ -65,15 +66,16 @@ function page_title_menu() {
/**
* Implementation of hook_theme().
* Implement hook_theme().
*/
function page_title_theme() {
return array(
'page_title_admin_settings' => array(
'arguments' => array('form' => NULL),
'render element' => 'form',
'file' => 'page_title.admin.inc',
),
'page_title_preprocess_page' => array(
'page_title_preprocess_html' => array(
'arguments' => array('vars' => NULL),
),
);
......@@ -81,7 +83,7 @@ function page_title_theme() {
/**
* Implementation of hook_node_type().
* Implement hook_node_type().
*
* Updates settings after a node type change.
*/
......@@ -117,7 +119,7 @@ function page_title_node_type($op, $info) {
/**
* Implementation of hook_form_alter().
* Implement hook_form_alter().
*/
function page_title_form_alter(&$form, $form_state, $form_id) {
// If we dont have permission to set the title then we need to abort this alter now!
......@@ -135,7 +137,9 @@ function page_title_form_alter(&$form, $form_state, $form_id) {
'#collapsed' => empty($page_title),
'#group' => 'additional_settings',
'#weight' => 35,
'#attached_js' => array(drupal_get_path('module', 'page_title') . '/page_title.js'),
'#attached' => array(
'js' => array(drupal_get_path('module', 'page_title') . '/page_title.js'),
),
);
$form['page_title']['page_title'] = array(
'#type' => 'textfield',
......@@ -221,7 +225,7 @@ function page_title_node_type_form_submit($form, &$form_state) {
/**
* Implementation of hook_node_load().
* Implement hook_node_load().
*/
function page_title_node_load($nodes) {
foreach ($nodes as $node) {
......@@ -233,7 +237,7 @@ function page_title_node_load($nodes) {
/**
* Implementation of hook_node_insert().
* Implement hook_node_insert().
*/
function page_title_node_insert($node) {
if (user_access('set page title') && isset($node->page_title) && drupal_strlen(trim($node->page_title)) > 0) {
......@@ -243,7 +247,7 @@ function page_title_node_insert($node) {
/**
* Implementation of hook_node_update().
* Implement hook_node_update().
*/
function page_title_node_update($node) {
if (user_access('set page title') && isset($node->page_title) && drupal_strlen(trim($node->page_title)) > 0) {
......@@ -253,7 +257,7 @@ function page_title_node_update($node) {
/**
* Implementation of hook_node_delete().
* Implement hook_node_delete().
*/
function page_title_node_delete($node) {
db_delete('page_title')->condition('type', 'node')->condition('id', $node->nid)->execute();
......@@ -261,7 +265,7 @@ function page_title_node_delete($node) {
/**
* Implementation of hook_taxonomy_term_update().
* Implement hook_taxonomy_term_update().
*/
function page_title_taxonomy_term_update($term) {
if (user_access('set page title')) {
......@@ -276,7 +280,7 @@ function page_title_taxonomy_term_update($term) {
/**
* Implementation of hook_taxonomy_term_delete().
* Implement hook_taxonomy_term_delete().
*/
function page_title_taxonomy_term_delete($term) {
db_delete('page_title')->condition('type', 'term')->condition('id', $term->tid)->execute();
......@@ -284,7 +288,7 @@ function page_title_taxonomy_term_delete($term) {
/**
* Implementation of hook_taxonomy_term_insert().
* Implement hook_taxonomy_term_insert().
*/
function page_title_taxonomy_term_insert($term) {
if (user_access('set page title') && isset($term->page_title) && drupal_strlen(trim($term->page_title)) > 0) {
......@@ -294,27 +298,8 @@ function page_title_taxonomy_term_insert($term) {
/**
* Implementation of hook_user().
* Implement hook_user_insert().
*/
/*
function page_title_user($op, &$edit, &$account) {
dpm(func_get_args());
switch ($op) {
case 'update':
if (user_access('set page title')) {
db_delete('page_title')->condition('type', 'user')->condition('id', $account->uid)->execute();
}
// Fallthrough to insert is intentional!
case 'insert':
if (isset($edit['page_title']) && drupal_strlen(trim($edit['page_title'])) > 0 && user_access('set page title')) {
db_insert('page_title')->fields(array('type' => 'user', 'id' => $account->uid, 'page_title' => $edit['page_title']))->execute();
}
break;
}
}
*/
function page_title_user_insert(&$edit, &$account, $category) {
if (user_access('set page title') && isset($edit['page_title']) && drupal_strlen(trim($edit['page_title'])) > 0) {
db_insert('page_title')->fields(array('type' => 'user', 'id' => $account->uid, 'page_title' => $edit['page_title']))->execute();
......@@ -322,6 +307,9 @@ function page_title_user_insert(&$edit, &$account, $category) {
}
/**
* Implement hook_user_update().
*/
function page_title_user_update(&$edit, &$account, $category) {
if (user_access('set page title')) {
if (isset($edit['page_title']) && drupal_strlen(trim($edit['page_title'])) > 0) {
......@@ -335,7 +323,7 @@ function page_title_user_update(&$edit, &$account, $category) {
/**
* Implementation of hook_user_cancel().
* Implement hook_user_cancel().
*/
function page_title_user_cancel(&$edit, &$account, $method) {
switch ($method) {
......@@ -348,8 +336,6 @@ function page_title_user_cancel(&$edit, &$account, $method) {
}
/**
* Simple wrapper function to get the currently set title for a page
*
......@@ -438,7 +424,7 @@ function page_title_set_title($title = NULL) {
/**
* Determines what title should be sent to the page template.
*
* This function gets called from the implementation of hook_page_preprocess
* This function gets called from the implementation of hook_preprocess_html
*
* @return
* string The page's title.
......@@ -508,7 +494,7 @@ function page_title_page_get_title() {
/**
* Implementation of hook_token_values().
* Implement hook_token_values().
*
* @param
* string The type of token being generated
......@@ -527,7 +513,7 @@ function page_title_tokens($type, $tokens, $data, $language = NULL, $sanitize =
/**
* Implementation of hook_token_info().
* Implement hook_token_info().
*/
function page_title_token_info() {
$result = array();
......@@ -542,28 +528,8 @@ function page_title_token_info() {
/**
* Implementation of hook_preprocess_page().
* Implement hook_preprocess_html().
*/
function page_title_preprocess_page(&$vars) {
function page_title_preprocess_html(&$vars) {
$vars['head_title'] = page_title_page_get_title();
}
/**
* Implementation of hook_content_extra_fields().
*
* This allows CCK to control the weight of the Page Title element as a "non-cck field"
*/
function page_title_content_extra_fields($type_name) {
$extra = array();
if (variable_get('page_title_type_'. $type_name .'_showfield', 0)) {
$extra['page_title'] = array(
'label' => t('Page Title'),
'description' => t('Page Title form.'),
'weight' => -4
);
}
return $extra;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment