Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
page_title
Commits
44a13981
Commit
44a13981
authored
Oct 29, 2009
by
Nicholas Thompson
Browse files
Work on improving compatibility with Drupal 7
parent
2ef74e0f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
87 deletions
+40
-87
page_title-admin-settings-form.tpl.php
page_title-admin-settings-form.tpl.php
+0
-14
page_title.admin.inc
page_title.admin.inc
+7
-8
page_title.js
page_title.js
+3
-1
page_title.module
page_title.module
+30
-64
No files found.
page_title-admin-settings-form.tpl.php
deleted
100644 → 0
View file @
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
);
page_title.admin.inc
View file @
44a13981
...
@@ -136,7 +136,8 @@ function page_title_admin_settings() {
...
@@ -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
();
$rows
=
array
();
foreach
(
element_children
(
$form
[
'patterns'
][
'pattern'
])
as
$key
)
{
foreach
(
element_children
(
$form
[
'patterns'
][
'pattern'
])
as
$key
)
{
$title
=
array
(
$title
=
array
(
...
@@ -144,18 +145,16 @@ function theme_page_title_admin_settings($form) {
...
@@ -144,18 +145,16 @@ function theme_page_title_admin_settings($form) {
'#required'
=>
$form
[
'patterns'
][
'pattern'
][
$key
][
'#required'
],
'#required'
=>
$form
[
'patterns'
][
'pattern'
][
$key
][
'#required'
],
);
);
unset
(
$form
[
'patterns'
][
'pattern'
][
$key
][
'#title'
]);
unset
(
$form
[
'patterns'
][
'pattern'
][
$key
][
'#title'
]);
$row
=
array
(
$row
=
array
(
drupal_
render
(
$title
),
render
(
$title
),
drupal_
render
(
$form
[
'patterns'
][
'scope'
][
$key
]),
render
(
$form
[
'patterns'
][
'scope'
][
$key
]),
drupal_
render
(
$form
[
'patterns'
][
'pattern'
][
$key
]),
render
(
$form
[
'patterns'
][
'pattern'
][
$key
]),
isset
(
$form
[
'patterns'
][
'showfield'
][
$key
.
'_showfield'
])
?
drupal_
render
(
$form
[
'patterns'
][
'showfield'
][
$key
.
'_showfield'
])
:
''
,
isset
(
$form
[
'patterns'
][
'showfield'
][
$key
.
'_showfield'
])
?
render
(
$form
[
'patterns'
][
'showfield'
][
$key
.
'_showfield'
])
:
''
,
);
);
$rows
[]
=
$row
;
$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
);
$output
.
=
drupal_render_children
(
$form
);
return
$output
;
return
$output
;
}
}
page_title.js
View file @
44a13981
// $Id$
(
function
(
$
)
{
(
function
(
$
)
{
Drupal
.
behaviors
.
pageTitleFieldsetSummaries
=
{
Drupal
.
behaviors
.
pageTitleFieldsetSummaries
=
{
attach
:
function
(
context
)
{
attach
:
function
(
context
)
{
$
(
'
fieldset#edit-page-title
'
,
context
).
setSummary
(
function
(
context
)
{
$
(
'
fieldset#edit-page-title
'
,
context
).
setSummary
(
function
(
context
)
{
var
pt
=
$
(
'
#edit-page-title-1
'
).
val
();
var
pt
=
$
(
'
input
'
,
context
).
val
();
return
pt
?
return
pt
?
Drupal
.
t
(
'
Page Title: @pt
'
,
{
'
@pt
'
:
pt
})
:
Drupal
.
t
(
'
Page Title: @pt
'
,
{
'
@pt
'
:
pt
})
:
...
...
page_title.module
View file @
44a13981
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
/**
/**
* Implement
ation of
hook_help().
* Implement hook_help().
*/
*/
function
page_title_help
(
$path
,
$arg
)
{
function
page_title_help
(
$path
,
$arg
)
{
$output
=
NULL
;
$output
=
NULL
;
...
@@ -38,7 +38,7 @@ function page_title_help($path, $arg) {
...
@@ -38,7 +38,7 @@ function page_title_help($path, $arg) {
/**
/**
* Implement
ation of
hook_perm().
* Implement hook_perm().
*/
*/
function
page_title_perm
()
{
function
page_title_perm
()
{
return
array
(
'set page title'
,
'administer page titles'
);
return
array
(
'set page title'
,
'administer page titles'
);
...
@@ -46,7 +46,7 @@ function page_title_perm() {
...
@@ -46,7 +46,7 @@ function page_title_perm() {
/**
/**
* Implement
ation of
hook_menu().
* Implement hook_menu().
*/
*/
function
page_title_menu
()
{
function
page_title_menu
()
{
$items
=
array
();
$items
=
array
();
...
@@ -58,6 +58,7 @@ function page_title_menu() {
...
@@ -58,6 +58,7 @@ function page_title_menu() {
'page arguments'
=>
array
(
'page_title_admin_settings'
),
'page arguments'
=>
array
(
'page_title_admin_settings'
),
'access arguments'
=>
array
(
'administer page titles'
),
'access arguments'
=>
array
(
'administer page titles'
),
'type'
=>
MENU_LOCAL_TASK
,
'type'
=>
MENU_LOCAL_TASK
,
'file'
=>
'page_title.admin.inc'
,
);
);
return
$items
;
return
$items
;
...
@@ -65,15 +66,16 @@ function page_title_menu() {
...
@@ -65,15 +66,16 @@ function page_title_menu() {
/**
/**
* Implement
ation of
hook_theme().
* Implement hook_theme().
*/
*/
function
page_title_theme
()
{
function
page_title_theme
()
{
return
array
(
return
array
(
'page_title_admin_settings'
=>
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
),
'arguments'
=>
array
(
'vars'
=>
NULL
),
),
),
);
);
...
@@ -81,7 +83,7 @@ function page_title_theme() {
...
@@ -81,7 +83,7 @@ function page_title_theme() {
/**
/**
* Implement
ation of
hook_node_type().
* Implement hook_node_type().
*
*
* Updates settings after a node type change.
* Updates settings after a node type change.
*/
*/
...
@@ -117,7 +119,7 @@ function page_title_node_type($op, $info) {
...
@@ -117,7 +119,7 @@ function page_title_node_type($op, $info) {
/**
/**
* Implement
ation of
hook_form_alter().
* Implement hook_form_alter().
*/
*/
function
page_title_form_alter
(
&
$form
,
$form_state
,
$form_id
)
{
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!
// 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) {
...
@@ -135,7 +137,9 @@ function page_title_form_alter(&$form, $form_state, $form_id) {
'#collapsed'
=>
empty
(
$page_title
),
'#collapsed'
=>
empty
(
$page_title
),
'#group'
=>
'additional_settings'
,
'#group'
=>
'additional_settings'
,
'#weight'
=>
35
,
'#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
(
$form
[
'page_title'
][
'page_title'
]
=
array
(
'#type'
=>
'textfield'
,
'#type'
=>
'textfield'
,
...
@@ -221,7 +225,7 @@ function page_title_node_type_form_submit($form, &$form_state) {
...
@@ -221,7 +225,7 @@ function page_title_node_type_form_submit($form, &$form_state) {
/**
/**
* Implement
ation of
hook_node_load().
* Implement hook_node_load().
*/
*/
function
page_title_node_load
(
$nodes
)
{
function
page_title_node_load
(
$nodes
)
{
foreach
(
$nodes
as
$node
)
{
foreach
(
$nodes
as
$node
)
{
...
@@ -233,7 +237,7 @@ function page_title_node_load($nodes) {
...
@@ -233,7 +237,7 @@ function page_title_node_load($nodes) {
/**
/**
* Implement
ation of
hook_node_insert().
* Implement hook_node_insert().
*/
*/
function
page_title_node_insert
(
$node
)
{
function
page_title_node_insert
(
$node
)
{
if
(
user_access
(
'set page title'
)
&&
isset
(
$node
->
page_title
)
&&
drupal_strlen
(
trim
(
$node
->
page_title
))
>
0
)
{
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) {
...
@@ -243,7 +247,7 @@ function page_title_node_insert($node) {
/**
/**
* Implement
ation of
hook_node_update().
* Implement hook_node_update().
*/
*/
function
page_title_node_update
(
$node
)
{
function
page_title_node_update
(
$node
)
{
if
(
user_access
(
'set page title'
)
&&
isset
(
$node
->
page_title
)
&&
drupal_strlen
(
trim
(
$node
->
page_title
))
>
0
)
{
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) {
...
@@ -253,7 +257,7 @@ function page_title_node_update($node) {
/**
/**
* Implement
ation of
hook_node_delete().
* Implement hook_node_delete().
*/
*/
function
page_title_node_delete
(
$node
)
{
function
page_title_node_delete
(
$node
)
{
db_delete
(
'page_title'
)
->
condition
(
'type'
,
'node'
)
->
condition
(
'id'
,
$node
->
nid
)
->
execute
();
db_delete
(
'page_title'
)
->
condition
(
'type'
,
'node'
)
->
condition
(
'id'
,
$node
->
nid
)
->
execute
();
...
@@ -261,7 +265,7 @@ function page_title_node_delete($node) {
...
@@ -261,7 +265,7 @@ function page_title_node_delete($node) {
/**
/**
* Implement
ation of
hook_taxonomy_term_update().
* Implement hook_taxonomy_term_update().
*/
*/
function
page_title_taxonomy_term_update
(
$term
)
{
function
page_title_taxonomy_term_update
(
$term
)
{
if
(
user_access
(
'set page title'
))
{
if
(
user_access
(
'set page title'
))
{
...
@@ -276,7 +280,7 @@ function page_title_taxonomy_term_update($term) {
...
@@ -276,7 +280,7 @@ function page_title_taxonomy_term_update($term) {
/**
/**
* Implement
ation of
hook_taxonomy_term_delete().
* Implement hook_taxonomy_term_delete().
*/
*/
function
page_title_taxonomy_term_delete
(
$term
)
{
function
page_title_taxonomy_term_delete
(
$term
)
{
db_delete
(
'page_title'
)
->
condition
(
'type'
,
'term'
)
->
condition
(
'id'
,
$term
->
tid
)
->
execute
();
db_delete
(
'page_title'
)
->
condition
(
'type'
,
'term'
)
->
condition
(
'id'
,
$term
->
tid
)
->
execute
();
...
@@ -284,7 +288,7 @@ function page_title_taxonomy_term_delete($term) {
...
@@ -284,7 +288,7 @@ function page_title_taxonomy_term_delete($term) {
/**
/**
* Implement
ation of
hook_taxonomy_term_insert().
* Implement hook_taxonomy_term_insert().
*/
*/
function
page_title_taxonomy_term_insert
(
$term
)
{
function
page_title_taxonomy_term_insert
(
$term
)
{
if
(
user_access
(
'set page title'
)
&&
isset
(
$term
->
page_title
)
&&
drupal_strlen
(
trim
(
$term
->
page_title
))
>
0
)
{
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) {
...
@@ -294,27 +298,8 @@ function page_title_taxonomy_term_insert($term) {
/**
/**
* Implement
ation 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
)
{
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
)
{
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
();
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) {
...
@@ -322,6 +307,9 @@ function page_title_user_insert(&$edit, &$account, $category) {
}
}
/**
* Implement hook_user_update().
*/
function
page_title_user_update
(
&
$edit
,
&
$account
,
$category
)
{
function
page_title_user_update
(
&
$edit
,
&
$account
,
$category
)
{
if
(
user_access
(
'set page title'
))
{
if
(
user_access
(
'set page title'
))
{
if
(
isset
(
$edit
[
'page_title'
])
&&
drupal_strlen
(
trim
(
$edit
[
'page_title'
]))
>
0
)
{
if
(
isset
(
$edit
[
'page_title'
])
&&
drupal_strlen
(
trim
(
$edit
[
'page_title'
]))
>
0
)
{
...
@@ -335,7 +323,7 @@ function page_title_user_update(&$edit, &$account, $category) {
...
@@ -335,7 +323,7 @@ function page_title_user_update(&$edit, &$account, $category) {
/**
/**
* Implement
ation of
hook_user_cancel().
* Implement hook_user_cancel().
*/
*/
function
page_title_user_cancel
(
&
$edit
,
&
$account
,
$method
)
{
function
page_title_user_cancel
(
&
$edit
,
&
$account
,
$method
)
{
switch
(
$method
)
{
switch
(
$method
)
{
...
@@ -348,8 +336,6 @@ function page_title_user_cancel(&$edit, &$account, $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
* Simple wrapper function to get the currently set title for a page
*
*
...
@@ -438,7 +424,7 @@ function page_title_set_title($title = NULL) {
...
@@ -438,7 +424,7 @@ function page_title_set_title($title = NULL) {
/**
/**
* Determines what title should be sent to the page template.
* 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
* @return
* string The page's title.
* string The page's title.
...
@@ -508,7 +494,7 @@ function page_title_page_get_title() {
...
@@ -508,7 +494,7 @@ function page_title_page_get_title() {
/**
/**
* Implement
ation of
hook_token_values().
* Implement hook_token_values().
*
*
* @param
* @param
* string The type of token being generated
* string The type of token being generated
...
@@ -527,7 +513,7 @@ function page_title_tokens($type, $tokens, $data, $language = NULL, $sanitize =
...
@@ -527,7 +513,7 @@ function page_title_tokens($type, $tokens, $data, $language = NULL, $sanitize =
/**
/**
* Implement
ation of
hook_token_info().
* Implement hook_token_info().
*/
*/
function
page_title_token_info
()
{
function
page_title_token_info
()
{
$result
=
array
();
$result
=
array
();
...
@@ -542,28 +528,8 @@ function page_title_token_info() {
...
@@ -542,28 +528,8 @@ function page_title_token_info() {
/**
/**
* Implement
ation 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
();
$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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment