Commit 816e4c96 authored by Nicholas Thompson's avatar Nicholas Thompson
Browse files

Coder Review clean up - mostly string concatenation and comma spaces.

parent 019ecfab
......@@ -18,7 +18,7 @@ function comment_page_title_alter(&$title) {
// to have a custom page title (ie, it's not a leftover from a previous
// setting), then use it.
if ( !empty($node->page_title) &&
variable_get('page_title_type_'. $node->type .'_showfield', 0) ) {
variable_get('page_title_type_' . $node->type . '_showfield', 0) ) {
$title = $node->page_title;
}
// Otherwise set the page-title token to the parent node title. Makes more
......@@ -49,7 +49,7 @@ function comment_page_title_pattern_alter(&$pattern, &$types) {
$types['taxonomy'] = current($types['node']->taxonomy);
}
if (is_numeric(arg(3)) && ($comment = menu_get_object('comment',3))) {
if (is_numeric(arg(3)) && ($comment = menu_get_object('comment', 3))) {
// Comment Reply...
$types['comment'] = $comment;
$pattern = variable_get('page_title_comment_child_reply', '');
......
......@@ -15,7 +15,7 @@ function forum_page_title_alter(&$title) {
// container or forum (rather than root).
if ( !strncmp($menu_item['path'], 'forum/%', 7) &&
($term = menu_get_object('taxonomy_term')) &&
variable_get('page_title_vocab_'. $term->vid .'_showfield', 0) &&
variable_get('page_title_vocab_' . $term->vid . '_showfield', 0) &&
($forum_title = page_title_load_title($term->tid, 'term')) ) {
$title = $forum_title;
}
......@@ -33,7 +33,7 @@ function forum_page_title_pattern_alter(&$pattern, &$types) {
($forum = menu_get_object('forum_forum', 1)) ) {
$types['term'] = $forum;
$forum_vid = variable_get('forum_nav_vocabulary', '');
$pattern = variable_get('page_title_vocab_'. $forum_vid, '');
$pattern = variable_get('page_title_vocab_' . $forum_vid, '');
$types['vocabulary'] = taxonomy_vocabulary_load($forum_vid);
}
// Otherwise it's the root - let's grab the root pattern.
......
......@@ -12,10 +12,10 @@
function node_page_title_alter(&$title) {
$menu_item = menu_get_item();
// Test if this is a node page.
if ( !strncmp($menu_item['path'],'node/%',6) &&
if ( !strncmp($menu_item['path'], 'node/%', 6) &&
($node = menu_get_object()) &&
!empty($node->page_title) &&
variable_get('page_title_type_'. $node->type .'_showfield', 0)) {
variable_get('page_title_type_' . $node->type . '_showfield', 0)) {
// If the node has a custom page title and the node type is configured
// to have a custom page title (ie, it's not a leftover from a previous
// setting), then use it.
......@@ -30,7 +30,7 @@ function node_page_title_alter(&$title) {
function node_page_title_pattern_alter(&$pattern, &$types) {
$menu_item = menu_get_item();
// Test if this is a node page.
if ( !strncmp($menu_item['path'],'node/%',6) &&
if ( !strncmp($menu_item['path'], 'node/%', 6) &&
$node = menu_get_object() ) {
$types['node'] = $node;
......@@ -58,7 +58,7 @@ function node_page_title_pattern_alter(&$pattern, &$types) {
}
}
$pattern = variable_get('page_title_type_'. $types['node']->type, '');
$pattern = variable_get('page_title_type_' . $types['node']->type, '');
}
}
......@@ -71,7 +71,7 @@ function node_page_title_settings() {
$types = node_type_get_types();
foreach ($types as $type) {
$settings['page_title_type_'. $type->type] = array(
$settings['page_title_type_' . $type->type] = array(
'label' => 'Content Type - %type',
'label arguments' => array('%type' => $type->name),
'scopes' => array('global', 'node', 'term', 'vocabulary'),
......
......@@ -13,8 +13,8 @@ function taxonomy_page_title_alter(&$title) {
$menu_item = menu_get_item();
// If we're looking at a taxonomy term page, get the term title.
if ( !strncmp($menu_item['path'], 'taxonomy/term/%', 15) &&
($term = menu_get_object('taxonomy_term',2)) &&
variable_get('page_title_vocab_'. $term->vid .'_showfield', 0) &&
($term = menu_get_object('taxonomy_term', 2)) &&
variable_get('page_title_vocab_' . $term->vid . '_showfield', 0) &&
($term_title = page_title_load_title($term->tid, 'term')) ) {
$title = $term_title;
}
......@@ -29,9 +29,9 @@ function taxonomy_page_title_pattern_alter(&$pattern, &$types) {
// Taxonomy Term Page
if ( !strncmp($menu_item['path'], 'taxonomy/term/%', 15) &&
($term = menu_get_object('taxonomy_term',2)) ) {
($term = menu_get_object('taxonomy_term', 2)) ) {
$types['term'] = $term;
$pattern = variable_get('page_title_vocab_'. $term->vid, '');
$pattern = variable_get('page_title_vocab_' . $term->vid, '');
}
}
......@@ -44,7 +44,7 @@ function taxonomy_page_title_settings() {
$vocabs = taxonomy_get_vocabularies();
foreach ($vocabs as $vocab) {
$settings['page_title_vocab_'. $vocab->vid] = array(
$settings['page_title_vocab_' . $vocab->vid] = array(
'label' => 'Vocabulary - %vocab_name',
'label arguments' => array('%vocab_name' => $vocab->name),
'scopes' => array('global', 'term', 'vocabulary'),
......
......@@ -45,7 +45,7 @@ function views_page_title_pattern_alter(&$pattern, &$types) {
}
}
// This is a view with no args provided, or the specific arg has no title - lets use the base display title
elseif($view->display_handler->display->display_plugin == 'page_with_page_title') {
elseif ($view->display_handler->display->display_plugin == 'page_with_page_title') {
$pattern = $view->display_handler->get_option('page_title_pattern');
}
}
......
......@@ -41,9 +41,9 @@ function page_title_admin_settings() {
);
if ($settings['show field']) {
$form['patterns']['showfield'][$key .'_showfield'] = array(
$form['patterns']['showfield'][$key . '_showfield'] = array(
'#type' => 'checkbox',
'#default_value' => variable_get($key .'_showfield', 0),
'#default_value' => variable_get($key . '_showfield', 0),
);
}
}
......
<?php
/**
* @file page_title.install
*
* Handles the install, uninstall and updating of Page Title
*/
/**
* Implementation of hook_schema().
......@@ -46,7 +51,7 @@ function page_title_update_6200() {
$display_settings = variable_get('page_title_display', array());
foreach ($display_settings as $type) {
if ($type) {
variable_set('page_title_type_'. $type .'_showfield', 1);
variable_set('page_title_type_' . $type . '_showfield', 1);
}
}
variable_del('page_title_display');
......@@ -76,7 +81,7 @@ function page_title_uninstall() {
}
// Clear the vocab specific variables
if(module_exists('taxonomy')) {
if (module_exists('taxonomy')) {
$vocabs = taxonomy_get_vocabularies();
foreach ($vocabs as $vid => $vocab) {
variable_del("page_title_vocab_{$vid}");
......
......@@ -18,19 +18,19 @@ function page_title_help($path, $arg) {
$output = NULL;
switch ($path) {
case 'admin/config/search/page-title' :
$output = '<p>'. t('Page Title provides control over the &lt;title> element on a page using token patterns and an optional textfield to override the title of the item (be it a node, term, user or other). The Token Scope column lets you know which tokens are available for this field (Global is always available). Please click on the <strong><em>more help&hellip;</em></strong> link below if you need further assistance.') .'</p>';
$output .= '<p>'. l(t('More Help...'), 'admin/help/page_title') .'</p>';
$output = '<p>' . t('Page Title provides control over the &lt;title> element on a page using token patterns and an optional textfield to override the title of the item (be it a node, term, user or other). The Token Scope column lets you know which tokens are available for this field (Global is always available). Please click on the <strong><em>more help&hellip;</em></strong> link below if you need further assistance.') . '</p>';
$output .= '<p>' . l(t('More Help...'), 'admin/help/page_title') . '</p>';
break;
case 'admin/help#page_title':
$output = '<p>'. t('Drupal\'s default page title follows one of two patterns:') .'</p>';
$output = '<p>' . t('Drupal\'s default page title follows one of two patterns:') . '</p>';
$items = array(
t('<strong>Default Page</strong>: <samp><em>page title</em> | <em>site name</em></samp>'),
t('<strong>Default Frontpage</strong>: <samp><em>site name</em> | <em>site slogan</em></samp>'),
);
$output .= theme('item_list', $items, NULL, 'ol');
$output .= '<p>'. t('The <strong>Page Title</strong> module lets you change these defaults in two ways. First, you can adjust the patterns below using the placeholders given. This will change the way the default page titles are created. Second, on enabled forms (curently node, term & user editing forms) you have the option of specifying a title that is different to the title of the item. This field only appears if the <em>Show Field</em> box is checked for the item. If a value is provided it will be used to generate the <samp>[current-page:page-title]</samp> placeholder however if it is left blank the <samp>[current-page:page-title]</samp> token will inherit the item\'s own title.') .'</p>';
$output .= '<p>'. t('The <samp>[current:page-title]</samp> token will default to the value returned from <samp>drupal_get_title</samp> if there is no value specified or no available page title field.') .'</p>';
$output .= '<p>'. t('Certain types of page title pattern have access to special tokens which others do not, depending on their <em>scope</em>. All patterns have access to the <strong>Global</strong> scope. Content type patterns have access to the <strong>Node</strong> tokens, vocabulary patterns have access to the <strong>Taxonomy</strong> tokens and finally the user patterns have access to the <strong>User</strong> tokens.') .'</p>';
$output .= '<p>' . t('The <strong>Page Title</strong> module lets you change these defaults in two ways. First, you can adjust the patterns below using the placeholders given. This will change the way the default page titles are created. Second, on enabled forms (curently node, term & user editing forms) you have the option of specifying a title that is different to the title of the item. This field only appears if the <em>Show Field</em> box is checked for the item. If a value is provided it will be used to generate the <samp>[current-page:page-title]</samp> placeholder however if it is left blank the <samp>[current-page:page-title]</samp> token will inherit the item\'s own title.') . '</p>';
$output .= '<p>' . t('The <samp>[current:page-title]</samp> token will default to the value returned from <samp>drupal_get_title</samp> if there is no value specified or no available page title field.') . '</p>';
$output .= '<p>' . t('Certain types of page title pattern have access to special tokens which others do not, depending on their <em>scope</em>. All patterns have access to the <strong>Global</strong> scope. Content type patterns have access to the <strong>Node</strong> tokens, vocabulary patterns have access to the <strong>Taxonomy</strong> tokens and finally the user patterns have access to the <strong>User</strong> tokens.') . '</p>';
break;
}
return $output;
......@@ -156,29 +156,29 @@ function page_title_node_type($op, $info) {
// Handle a content type rename
if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) {
// Load the old node type settings.
$temp = variable_get('page_title_type_'. $info->old_type, '');
$temp = variable_get('page_title_type_' . $info->old_type, '');
// If the settings aren't empty, then save them into the new type
if (!empty($temp)) {
variable_set('page_title_type_'. $info->type, $temp);
variable_set('page_title_type_' . $info->type, $temp);
}
// Delete the old setting
variable_del('page_title_type_'. $info->old_type);
variable_del('page_title_type_' . $info->old_type);
// Essentially, do the same as above but with the _showfield suffix for the node type
$temp = variable_get('page_title_type_'. $info->old_type .'_showfield', 0);
$temp = variable_get('page_title_type_' . $info->old_type . '_showfield', 0);
if ($temp) {
variable_set('page_title_type_'. $info->type .'_showfield', $temp);
variable_set('page_title_type_' . $info->type . '_showfield', $temp);
}
variable_del('page_title_type_'. $info->old_type .'_showfield');
variable_del('page_title_type_' . $info->old_type . '_showfield');
}
// If deleted, remove the variables
if ($op == 'delete') {
variable_del('page_title_type_'. $info->type);
variable_del('page_title_type_'. $info->type .'_showfield');
variable_del('page_title_type_' . $info->type);
variable_del('page_title_type_' . $info->type . '_showfield');
}
}
......@@ -194,7 +194,7 @@ function page_title_form_alter(&$form, $form_state, $form_id) {
// If we're editing a node...
if (!empty($form['#node_edit_form'])) {
// ... and the show field is enabled for this node type
if (variable_get('page_title_type_'. $form['type']['#value'] .'_showfield', 0)) {
if (variable_get('page_title_type_' . $form['type']['#value'] . '_showfield', 0)) {
$page_title = isset($form['#node']->page_title) ? $form['#node']->page_title : NULL;
$form['page_title'] = array(
'#type' => 'fieldset',
......@@ -253,7 +253,7 @@ function page_title_form_taxonomy_form_term_alter(&$form, $form_state) {
//if ($form['delete']['#value'] === TRUE) return;
// Check the term's vocab has the show field enabled
if (variable_get('page_title_vocab_'. $form['#vocabulary']->vid .'_showfield', 0)) {
if (variable_get('page_title_vocab_' . $form['#vocabulary']->vid . '_showfield', 0)) {
$form['advanced']['page_title'] = array(
'#type' => 'textfield',
'#title' => t('Page title'),
......@@ -274,7 +274,7 @@ function page_title_form_forum_form_container_alter(&$form, $form_state) {
$forum_vid = variable_get('forum_nav_vocabulary', 0);
// Check the forum vocab has the show field enabled
if (variable_get('page_title_vocab_'. $forum_vid .'_showfield', 0)) {
if (variable_get('page_title_vocab_' . $forum_vid . '_showfield', 0)) {
$form['page_title'] = array(
'#type' => 'textfield',
'#title' => t('Page title'),
......@@ -321,13 +321,13 @@ function page_title_form_node_type_form_alter(&$form, $form_state) {
'#options' => array(
'show_field' => t('Show field'),
),
'#default_value' => variable_get('page_title_type_'. $form['#node_type']->type .'_showfield', 0) ? array('show_field') : array(),
'#default_value' => variable_get('page_title_type_' . $form['#node_type']->type . '_showfield', 0) ? array('show_field') : array(),
);
$form['page_title']['pattern'] = array(
'#type' => 'textfield',
'#title' => t('Page Title Pattern'),
'#default_value' => variable_get('page_title_type_'. $form['#node_type']->type, ''),
'#default_value' => variable_get('page_title_type_' . $form['#node_type']->type, ''),
'#description' => t('Enter the <em>Page Title</em> pattern you want to use for this node type. For more information, please use the !link settings page', array('!link' => l('Page Title', 'admin/content/page_title'))),
'#maxlength' => 255,
);
......@@ -341,11 +341,11 @@ function page_title_form_node_type_form_alter(&$form, $form_state) {
*/
function page_title_node_type_form_submit($form, &$form_state) {
$show_field = $form_state['values']['page_title']['show_field']['show_field'] ? 1 : 0;
variable_set('page_title_type_'. $form_state['values']['type'] .'_showfield', $show_field);
variable_set('page_title_type_'. $form_state['values']['type'], $form_state['values']['page_title']['pattern']);
variable_set('page_title_type_' . $form_state['values']['type'] . '_showfield', $show_field);
variable_set('page_title_type_' . $form_state['values']['type'], $form_state['values']['page_title']['pattern']);
// For some reason the node module adds the fieldset as a separate entry in the variables table... we dont want this!
variable_del('page_title_'. $form_state['values']['type']);
variable_del('page_title_' . $form_state['values']['type']);
}
......@@ -581,8 +581,8 @@ function page_title_init() {
// Include relevant page_title.inc's. We cannot use drupal_load() here due to the folder structure.
// We also avoice using include_once due to its performance hit on the Filesystem
foreach (page_title_get_module_apis() as $module => $info) {
if (file_exists(DRUPAL_ROOT ."/{$info['path']}/{$module}.page_title.inc")) {
include DRUPAL_ROOT ."/{$info['path']}/{$module}.page_title.inc";
if (file_exists(DRUPAL_ROOT . "/{$info['path']}/{$module}.page_title.inc")) {
include DRUPAL_ROOT . "/{$info['path']}/{$module}.page_title.inc";
}
}
......@@ -685,11 +685,11 @@ function page_title_views_plugins() {
'accept attachments' => TRUE,
'admin' => t('Page with Page Title'),
'module' => 'page_title',
'path' => drupal_get_path('module', 'page_title') .'/views/plugins',
'path' => drupal_get_path('module', 'page_title') . '/views/plugins',
'file' => 'page_title_plugin_display_page_with_page_title.inc',
'handler' => 'page_title_plugin_display_page_with_page_title',
'theme' => 'views_view',
'theme path' => drupal_get_path('module', 'views') .'/theme',
'theme path' => drupal_get_path('module', 'views') . '/theme',
'theme file' => 'theme.inc',
),
),
......@@ -775,7 +775,7 @@ function page_title_get_module_apis() {
function page_title_page_title_api() {
return array(
'api' => 1,
'path' => drupal_get_path('module', 'page_title') .'/modules',
'path' => drupal_get_path('module', 'page_title') . '/modules',
);
}
......
......@@ -45,8 +45,8 @@ class PageTitleTestCase extends DrupalWebTestCase {
$title = strtr($pattern, $tokens);
// Do some verbose output
$this->pass(t('Pattern: %pat', array('%pat' => '<title>'. $pattern .'</title>')));
$this->pass(t('Looking for title: %title', array('%title' => '<title>'. $title .'</title>')));
$this->pass(t('Pattern: %pat', array('%pat' => '<title>' . $pattern . '</title>')));
$this->pass(t('Looking for title: %title', array('%title' => '<title>' . $title . '</title>')));
// Look for the title in the content
$res = $this->assertRaw($title, t('Correct page title found in the <head> for: %section', array('%section' => $section)), 'Page Title');
......@@ -127,15 +127,15 @@ class PageTitleTestCase extends DrupalWebTestCase {
$this->pass(t('Created Node !nid', array('!nid' => $node->nid)), 'Page Title');
// Load the node page and check for the title in the head
$this->pageTitleCheck('node/'. $node->nid, $settings['page_title_type_page'], array('[current-page:page-title]' => $node->title), 'Page Node Type');
$this->pageTitleCheck('node/' . $node->nid, $settings['page_title_type_page'], array('[current-page:page-title]' => $node->title), 'Page Node Type');
// Post a page_title into the node and reload the node
$edit['page_title'] = 'I am a test Page Title field';
$this->drupalPost('node/'. $node->nid .'/edit', $edit, 'Save');
$this->drupalPost('node/' . $node->nid . '/edit', $edit, 'Save');
$node = node_load($node->nid, NULL, TRUE);
// Node load the node page and check for the title in the head
$this->pageTitleCheck('node/'. $node->nid, $settings['page_title_type_page'], array('[current-page:page-title]' => $node->page_title), 'Page Node Type');
$this->pageTitleCheck('node/' . $node->nid, $settings['page_title_type_page'], array('[current-page:page-title]' => $node->page_title), 'Page Node Type');
......@@ -181,7 +181,7 @@ class PageTitleTestCase extends DrupalWebTestCase {
// Node load the node page and check for the title in the head
$this->pageTitleCheck('node/'. $forum_node->nid, $settings['page_title_type_forum'], array('[current-page:page-title]' => $forum_node->title), 'Forum Topic');
$this->pageTitleCheck('node/' . $forum_node->nid, $settings['page_title_type_forum'], array('[current-page:page-title]' => $forum_node->title), 'Forum Topic');
//Now test the forum root...
......
......@@ -22,7 +22,7 @@ class page_title_plugin_display_page_with_page_title extends views_plugin_displa
$title = t('None');
}
elseif (drupal_strlen($title) > 16) {
$title = drupal_substr($title, 0, 16) .'...';
$title = drupal_substr($title, 0, 16) . '...';
}
$options['page_title_pattern'] = array(
......
Supports Markdown
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