/[drupal]/contributions/modules/page_title/page_title.module
ViewVC logotype

Diff of /contributions/modules/page_title/page_title.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.19, Sat Aug 15 22:05:04 2009 UTC revision 1.20, Thu Oct 29 18:11:19 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: page_title.module,v 1.18.2.14 2009/06/17 14:24:39 njt1982 Exp $  // $Id: page_title.module,v 1.19 2009/08/15 22:05:04 njt1982 Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 13  Line 13 
13    
14    
15  /**  /**
16   * Implementation of hook_help().   * Implement hook_help().
17   */   */
18  function page_title_help($path, $arg) {  function page_title_help($path, $arg) {
19    $output = NULL;    $output = NULL;
# Line 38  function page_title_help($path, $arg) { Line 38  function page_title_help($path, $arg) {
38    
39    
40  /**  /**
41   * Implementation of hook_perm().   * Implement hook_perm().
42   */   */
43  function page_title_perm() {  function page_title_perm() {
44    return array('set page title', 'administer page titles');    return array('set page title', 'administer page titles');
# Line 46  function page_title_perm() { Line 46  function page_title_perm() {
46    
47    
48  /**  /**
49   * Implementation of hook_menu().   * Implement hook_menu().
50   */   */
51  function page_title_menu() {  function page_title_menu() {
52    $items = array();    $items = array();
# Line 58  function page_title_menu() { Line 58  function page_title_menu() {
58      'page arguments' => array('page_title_admin_settings'),      'page arguments' => array('page_title_admin_settings'),
59      'access arguments' => array('administer page titles'),      'access arguments' => array('administer page titles'),
60      'type' => MENU_LOCAL_TASK,      'type' => MENU_LOCAL_TASK,
61        'file' => 'page_title.admin.inc',
62    );    );
63    
64    return $items;    return $items;
# Line 65  function page_title_menu() { Line 66  function page_title_menu() {
66    
67    
68  /**  /**
69   * Implementation of hook_theme().   * Implement hook_theme().
70   */   */
71  function page_title_theme() {  function page_title_theme() {
72    return array(    return array(
73      'page_title_admin_settings' => array(      'page_title_admin_settings' => array(
74        'arguments' => array('form' => NULL),        'render element' => 'form',
75          'file' => 'page_title.admin.inc',
76      ),      ),
77    
78      'page_title_preprocess_page' => array(      'page_title_preprocess_html' => array(
79        'arguments' => array('vars' => NULL),        'arguments' => array('vars' => NULL),
80      ),      ),
81    );    );
# Line 81  function page_title_theme() { Line 83  function page_title_theme() {
83    
84    
85  /**  /**
86   * Implementation of hook_node_type().   * Implement hook_node_type().
87   *   *
88   * Updates settings after a node type change.   * Updates settings after a node type change.
89   */   */
# Line 117  function page_title_node_type($op, $info Line 119  function page_title_node_type($op, $info
119    
120    
121  /**  /**
122   * Implementation of hook_form_alter().   * Implement hook_form_alter().
123   */   */
124  function page_title_form_alter(&$form, $form_state, $form_id) {  function page_title_form_alter(&$form, $form_state, $form_id) {
125    // 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!
# Line 135  function page_title_form_alter(&$form, $ Line 137  function page_title_form_alter(&$form, $
137          '#collapsed' => empty($page_title),          '#collapsed' => empty($page_title),
138          '#group' => 'additional_settings',          '#group' => 'additional_settings',
139          '#weight' => 35,          '#weight' => 35,
140          '#attached_js' => array(drupal_get_path('module', 'page_title') . '/page_title.js'),          '#attached' => array(
141              'js' => array(drupal_get_path('module', 'page_title') . '/page_title.js'),
142            ),
143        );        );
144        $form['page_title']['page_title'] = array(        $form['page_title']['page_title'] = array(
145          '#type' => 'textfield',          '#type' => 'textfield',
# Line 221  function page_title_node_type_form_submi Line 225  function page_title_node_type_form_submi
225    
226    
227  /**  /**
228   * Implementation of hook_node_load().   * Implement hook_node_load().
229   */   */
230  function page_title_node_load($nodes) {  function page_title_node_load($nodes) {
231    foreach ($nodes as $node) {    foreach ($nodes as $node) {
# Line 233  function page_title_node_load($nodes) { Line 237  function page_title_node_load($nodes) {
237    
238    
239  /**  /**
240   * Implementation of hook_node_insert().   * Implement hook_node_insert().
241   */   */
242  function page_title_node_insert($node) {  function page_title_node_insert($node) {
243    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) {
# Line 243  function page_title_node_insert($node) { Line 247  function page_title_node_insert($node) {
247    
248    
249  /**  /**
250   * Implementation of hook_node_update().   * Implement hook_node_update().
251   */   */
252  function page_title_node_update($node) {  function page_title_node_update($node) {
253    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) {
# Line 253  function page_title_node_update($node) { Line 257  function page_title_node_update($node) {
257    
258    
259  /**  /**
260   * Implementation of hook_node_delete().   * Implement hook_node_delete().
261   */   */
262  function page_title_node_delete($node) {  function page_title_node_delete($node) {
263    db_delete('page_title')->condition('type', 'node')->condition('id', $node->nid)->execute();    db_delete('page_title')->condition('type', 'node')->condition('id', $node->nid)->execute();
# Line 261  function page_title_node_delete($node) { Line 265  function page_title_node_delete($node) {
265    
266    
267  /**  /**
268   * Implementation of hook_taxonomy_term_update().   * Implement hook_taxonomy_term_update().
269   */   */
270  function page_title_taxonomy_term_update($term) {  function page_title_taxonomy_term_update($term) {
271    if (user_access('set page title')) {    if (user_access('set page title')) {
# Line 276  function page_title_taxonomy_term_update Line 280  function page_title_taxonomy_term_update
280    
281    
282  /**  /**
283   * Implementation of hook_taxonomy_term_delete().   * Implement hook_taxonomy_term_delete().
284   */   */
285  function page_title_taxonomy_term_delete($term) {  function page_title_taxonomy_term_delete($term) {
286    db_delete('page_title')->condition('type', 'term')->condition('id', $term->tid)->execute();    db_delete('page_title')->condition('type', 'term')->condition('id', $term->tid)->execute();
# Line 284  function page_title_taxonomy_term_delete Line 288  function page_title_taxonomy_term_delete
288    
289    
290  /**  /**
291   * Implementation of hook_taxonomy_term_insert().   * Implement hook_taxonomy_term_insert().
292   */   */
293  function page_title_taxonomy_term_insert($term) {  function page_title_taxonomy_term_insert($term) {
294    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) {
# Line 294  function page_title_taxonomy_term_insert Line 298  function page_title_taxonomy_term_insert
298    
299    
300  /**  /**
301   * Implementation of hook_user().   * Implement hook_user_insert().
302   */   */
 /*  
 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;  
   }  
 }  
 */  
   
   
303  function page_title_user_insert(&$edit, &$account, $category) {  function page_title_user_insert(&$edit, &$account, $category) {
304    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) {
305      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();
# Line 322  function page_title_user_insert(&$edit, Line 307  function page_title_user_insert(&$edit,
307  }  }
308    
309    
310    /**
311     * Implement hook_user_update().
312     */
313  function page_title_user_update(&$edit, &$account, $category) {  function page_title_user_update(&$edit, &$account, $category) {
314    if (user_access('set page title')) {    if (user_access('set page title')) {
315      if (isset($edit['page_title']) && drupal_strlen(trim($edit['page_title'])) > 0) {      if (isset($edit['page_title']) && drupal_strlen(trim($edit['page_title'])) > 0) {
# Line 335  function page_title_user_update(&$edit, Line 323  function page_title_user_update(&$edit,
323    
324    
325  /**  /**
326   * Implementation of hook_user_cancel().   * Implement hook_user_cancel().
327   */   */
328  function page_title_user_cancel(&$edit, &$account, $method) {  function page_title_user_cancel(&$edit, &$account, $method) {
329    switch ($method) {    switch ($method) {
# Line 348  function page_title_user_cancel(&$edit, Line 336  function page_title_user_cancel(&$edit,
336  }  }
337    
338    
   
   
339  /**  /**
340   * Simple wrapper function to get the currently set title for a page   * Simple wrapper function to get the currently set title for a page
341   *   *
# Line 438  function page_title_set_title($title = N Line 424  function page_title_set_title($title = N
424  /**  /**
425   * Determines what title should be sent to the page template.   * Determines what title should be sent to the page template.
426   *   *
427   * This function gets called from the implementation of hook_page_preprocess   * This function gets called from the implementation of hook_preprocess_html
428   *   *
429   * @return   * @return
430   *   string The page's title.   *   string The page's title.
# Line 508  function page_title_page_get_title() { Line 494  function page_title_page_get_title() {
494    
495    
496  /**  /**
497   * Implementation of hook_token_values().   * Implement hook_token_values().
498   *   *
499   * @param   * @param
500   *   string The type of token being generated   *   string The type of token being generated
# Line 527  function page_title_tokens($type, $token Line 513  function page_title_tokens($type, $token
513    
514    
515  /**  /**
516   * Implementation of hook_token_info().   * Implement hook_token_info().
517   */   */
518  function page_title_token_info() {  function page_title_token_info() {
519    $result = array();    $result = array();
# Line 542  function page_title_token_info() { Line 528  function page_title_token_info() {
528    
529    
530  /**  /**
531   * Implementation of hook_preprocess_page().   * Implement hook_preprocess_html().
532   */   */
533  function page_title_preprocess_page(&$vars) {  function page_title_preprocess_html(&$vars) {
534    $vars['head_title'] = page_title_page_get_title();    $vars['head_title'] = page_title_page_get_title();
535  }  }
   
   
 /**  
  * 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;  
 }  

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.2