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
2ef74e0f
Commit
2ef74e0f
authored
Aug 15, 2009
by
Nicholas Thompson
Browse files
Work on porting Page Title to Drupal 7 - forgot to add new JS and admin files.
parent
ff38c2e7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
177 additions
and
0 deletions
+177
-0
page_title.admin.inc
page_title.admin.inc
+161
-0
page_title.js
page_title.js
+16
-0
No files found.
page_title.admin.inc
0 → 100644
View file @
2ef74e0f
<?php
// $Id$
/**
* @file
* Admin include file.
*/
/**
* Displays the form for the standard settings tab.
*
* @return
* array A structured array for use with Forms API.
*/
function
page_title_admin_settings
()
{
// Define a default looking 'form element' for setting.
$showfield_form_element
=
array
(
'#type'
=>
'checkbox'
,
);
// Define a default looking 'form element' for setting.
$pattern_form_element
=
array
(
'#type'
=>
'textfield'
,
'#size'
=>
30
,
'#maxlength'
=>
256
,
);
// Define the basic scope column values
$form
[
'patterns'
][
'scope'
]
=
array
(
'page_title_default'
=>
array
(
'#markup'
=>
t
(
'Global Only'
),),
'page_title_front'
=>
array
(
'#markup'
=>
t
(
'Global Only'
),),
'page_title_user'
=>
array
(
'#markup'
=>
t
(
'User'
),),
);
// Define the 'default' token patterns
$form
[
'patterns'
][
'pattern'
]
=
array
(
'page_title_default'
=>
array
(
'#title'
=>
t
(
'Default'
),
'#default_value'
=>
variable_get
(
'page_title_default'
,
'[site:page-title] | [site:name]'
),
'#required'
=>
TRUE
,
)
+
$pattern_form_element
,
'page_title_front'
=>
array
(
'#title'
=>
t
(
'Frontpage'
),
'#default_value'
=>
variable_get
(
'page_title_front'
,
'[site:name] | [site:slogan]'
),
)
+
$pattern_form_element
,
'page_title_user'
=>
array
(
'#title'
=>
t
(
'User Profile'
),
'#default_value'
=>
variable_get
(
'page_title_user'
,
''
),
)
+
$pattern_form_element
,
);
// Define the "showfield" checkbox for the user profile page
$form
[
'patterns'
][
'showfield'
][
'page_title_user_showfield'
]
=
array
(
'#default_value'
=>
variable_get
(
'page_title_user_showfield'
,
0
),
)
+
$showfield_form_element
;
// Definate the patterns per-node-type
$types
=
node_type_get_types
();
foreach
(
$types
as
$type
)
{
// Define the node-type key
$key
=
'page_title_type_'
.
$type
->
type
;
// Pattern entry
$form
[
'patterns'
][
'pattern'
][
$key
]
=
array
(
'#title'
=>
t
(
'Content Type - %type'
,
array
(
'%type'
=>
$type
->
name
)),
'#default_value'
=>
variable_get
(
$key
,
''
),
)
+
$pattern_form_element
;
$form
[
'patterns'
][
'showfield'
][
$key
.
'_showfield'
]
=
array
(
'#default_value'
=>
variable_get
(
$key
.
'_showfield'
,
0
),
)
+
$showfield_form_element
;
$form
[
'patterns'
][
'scope'
][
$key
]
=
array
(
'#markup'
=>
t
(
'Node'
),);
}
// Definate the patterns per-vocab-type - if Taxonomy Module is enabled
if
(
module_exists
(
'taxonomy'
))
{
$vocabs
=
taxonomy_get_vocabularies
();
foreach
(
$vocabs
as
$vocab
)
{
// Define the vocab key
$key
=
'page_title_vocab_'
.
$vocab
->
vid
;
// Pattern entry
$form
[
'patterns'
][
'pattern'
][
$key
]
=
array
(
'#title'
=>
t
(
'Vocabulary - %vocab_name'
,
array
(
'%vocab_name'
=>
$vocab
->
name
)),
'#default_value'
=>
variable_get
(
$key
,
''
),
)
+
$pattern_form_element
;
$form
[
'patterns'
][
'showfield'
][
$key
.
'_showfield'
]
=
array
(
'#default_value'
=>
variable_get
(
$key
.
'_showfield'
,
0
),
)
+
$showfield_form_element
;
$form
[
'patterns'
][
'scope'
][
$key
]
=
array
(
'#markup'
=>
t
(
'Taxonomy'
),);
}
}
// Add the blog homepage pattern field
if
(
module_exists
(
'blog'
))
{
$key
=
'page_title_blog'
;
$form
[
'patterns'
][
'pattern'
][
$key
]
=
array
(
'#title'
=>
t
(
'Blog Homepage'
),
'#default_value'
=>
variable_get
(
$key
,
''
),
)
+
$pattern_form_element
;
$form
[
'patterns'
][
'scope'
][
$key
]
=
array
(
'#markup'
=>
t
(
'User'
),);
}
// Define the page pattern text field. This is appended to any page requests containing 'page=[0-9]+' in the query string
$form
[
'page_title_pager_pattern'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Pattern for pages that contain a pager'
),
'#default_value'
=>
variable_get
(
'page_title_pager_pattern'
,
''
),
'#description'
=>
t
(
'This pattern will be appended to a page title for any given page with a pager on it'
),
);
// Add the token help to a collapsed fieldset at the end of the configuration page.
/*
$form['token_help'] = array(
'#type' => 'fieldset',
'#title' => t('Available Tokens List'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['token_help']['content'] = array(
'#type' => 'markup',
'#value' => theme('token_help'),
);*/
$form
=
system_settings_form
(
$form
);
unset
(
$form
[
'#theme'
]);
return
$form
;
}
function
theme_page_title_admin_settings
(
$form
)
{
$rows
=
array
();
foreach
(
element_children
(
$form
[
'patterns'
][
'pattern'
])
as
$key
)
{
$title
=
array
(
'#markup'
=>
$form
[
'patterns'
][
'pattern'
][
$key
][
'#title'
],
'#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'
])
:
''
,
);
$rows
[]
=
$row
;
}
$output
=
theme
(
'table'
,
array
(
t
(
'Page Type'
),
t
(
'Token Scope'
),
t
(
'Pattern'
),
t
(
'Show Field'
)),
$rows
);
$output
.
=
drupal_render_children
(
$form
);
return
$output
;
}
page_title.js
0 → 100644
View file @
2ef74e0f
(
function
(
$
)
{
Drupal
.
behaviors
.
pageTitleFieldsetSummaries
=
{
attach
:
function
(
context
)
{
$
(
'
fieldset#edit-page-title
'
,
context
).
setSummary
(
function
(
context
)
{
var
pt
=
$
(
'
#edit-page-title-1
'
).
val
();
return
pt
?
Drupal
.
t
(
'
Page Title: @pt
'
,
{
'
@pt
'
:
pt
})
:
Drupal
.
t
(
'
No Page Title
'
);
});
}
};
})(
jQuery
);
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