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

Diff of /contributions/modules/taxonomy_theme/taxonomy_theme.module

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

revision 1.48, Mon Oct 23 06:50:50 2006 UTC revision 1.49, Sun Jun 8 15:21:03 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: taxonomy_theme.module,v 1.47 2006/10/09 22:14:49 profix898 Exp $  // $Id: taxonomy_theme.module,v 1.48 2006/10/23 06:50:50 profix898 Exp $
3    
4    /**
5     * Implementation of hook_theme()
6     */
7    function taxonomy_theme_theme() {
8      return array(
9        'taxonomy_theme_table' => array(
10          'arguments' => array('form' => NULL),
11        )
12      );
13    }
14    
15  /**  /**
16   * Implementation of hook_perm().   * Implementation of hook_perm().
17   */   */
18  function taxonomy_theme_perm() {  function taxonomy_theme_perm() {
19    return array('administer taxonomy_theme', 'assign node themes');    return array('administer taxonomy theme');
20  }  }
21    
22  /**  /**
23   * Implementation of hook_menu().   * Implementation of hook_menu().
24   */   */
25  function taxonomy_theme_menu($may_cache) {  function taxonomy_theme_menu() {
26    $items = array();    $items = array();
27      $items['admin/settings/themekey/taxonomy'] = array(
28    if ($may_cache) {      'title' => 'Taxonomy',
29      $items[] = array(      'access callback' => 'user_access',
30        'path' => 'admin/settings/taxonomy_theme',      'access arguments' => array('administer taxonomy theme'),
31        'title' => t('Taxonomy Theme'),      'file' => 'taxonomy_theme_admin.inc',
32        'description' => t('Assign themes to taxonomy terms/vocabs and Drupal pathes.'),      'page callback' => 'drupal_get_form',
33        'callback' => 'taxonomy_theme_admin',      'page arguments' => array('taxonomy_theme_admin_form'),
34        'callback arguments' => 'taxonomy_theme_admin_form',      'type' => MENU_LOCAL_TASK,
35        'access' => user_access('administer taxonomy_theme'),      'weight' => 3
36      );    );
37      $items[] = array(    $items['admin/settings/themekey/taxonomy/confirm'] = array(
38        'path' => 'admin/settings/taxonomy_theme/admin',      'access callback' => 'user_access',
39        'title' => t('Global'),      'access arguments' => array('administer taxonomy theme'),
40        'type' => MENU_DEFAULT_LOCAL_TASK,      'file' => 'taxonomy_theme_admin.inc',
41        'weight' => 0      'page callback' => 'drupal_get_form',
42      );      'page arguments' => array('_taxonomy_theme_admin_form_confirm'),
43      if (variable_get('taxonomy_theme_enable', 0)) {      'type' => MENU_CALLBACK
44        $items[] = array(    );
45          'path' => 'admin/settings/taxonomy_theme/taxonomy',  
         'title' => t('Taxonomy'),  
         'callback' => 'taxonomy_theme_admin',  
         'callback arguments' => 'taxonomy_theme_admin_taxonomy_form',  
         'access' => user_access('administer taxonomy_theme'),  
         'type' => MENU_LOCAL_TASK,  
         'weight' => 1  
       );  
       if (module_exists('forum') && variable_get('taxonomy_theme_method', 0)) {  
         $items[] = array(  
           'path' => 'admin/settings/taxonomy_theme/forum',  
           'title' => t('Forum'),  
           'callback' => 'taxonomy_theme_admin',  
           'callback arguments' => 'taxonomy_theme_admin_forum_form',  
           'access' => user_access('administer taxonomy_theme'),  
           'type' => MENU_LOCAL_TASK,  
           'weight' => 2  
         );  
       }  
       if (variable_get('taxonomy_theme_extended_enable', 0)) {  
         $items[] = array(  
           'path' => 'admin/settings/taxonomy_theme/extended',  
           'title' => t('Extended (Pathes)'),  
           'callback' => 'taxonomy_theme_admin',  
           'callback arguments' => 'taxonomy_theme_admin_extended_form',  
           'access' => user_access('administer taxonomy_theme'),  
           'type' => MENU_LOCAL_TASK,  
           'weight' => 3  
         );  
       }  
     }  
   }  
   else {  
     // perform theme selection and assign theme (using init_theme)  
     if (variable_get('taxonomy_theme_enable', 0)) {  
       _taxonomy_theme_assign();  
     }  
   }  
   
46    return $items;    return $items;
47  }  }
48    
49  /**  /**
50   * function taxonomy_theme_admin().   * Implementation of hook_form_alter().
51   */   */
52  function taxonomy_theme_admin($form) {  function taxonomy_theme_form_alter(&$form, $form_state, $form_id) {
53    require_once (drupal_get_path('module', 'taxonomy_theme').'/taxonomy_theme_admin.inc');    if (in_array($form_id, array('taxonomy_form_term', 'taxonomy_form_vocabulary')) && user_access('administer taxonomy_theme')) {
54    return drupal_get_form($form);      require_once(drupal_get_path('module', 'taxonomy_theme') .'/taxonomy_theme_admin.inc');
55        _taxonomy_theme_form_alter($form, $form_state, $form_id);
56      }
57  }  }
58    
59  /**  /**
60   * Implementation of hook_form_alter().   * Function taxonomy_theme_form_alter_submit().
61   */   */
62  function taxonomy_theme_form_alter($form_id, &$form) {  function taxonomy_theme_form_alter_submit($form, &$form_state) {
63    if (($form_id == 'taxonomy_form_term')    require_once(drupal_get_path('module', 'taxonomy_theme') .'/taxonomy_theme_admin.inc');
64          || ($form_id == 'taxonomy_form_vocabulary')    _taxonomy_theme_form_alter_submit($form, $form_state);
         || ($form_id == 'forum_form_forum')  
         || ($form_id == $form['type']['#value'].'_node_form')  
         || ($form_id == 'node_type_form')  
         || ($form_id == 'views_edit_view')  
       ) {  
     require_once (drupal_get_path('module', 'taxonomy_theme').'/taxonomy_theme_admin.inc');  
     _taxonomy_theme_form_alter($form_id, $form);  
   }  
65  }  }
66    
67  /**  /**
68   * function _taxonomy_theme_assign().   * Implementation of hook_taxonomy().
69   */   */
70  function _taxonomy_theme_assign() {  function taxonomy_theme_taxonomy($op, $type, $array) {
71    global $custom_theme;    require_once(drupal_get_path('module', 'themekey') .'/themekey_build.inc');
72    $uri = $_GET['q'];    //
73    $default_theme = variable_get('theme_default', 'bluemarine');    if ($type == 'vocabulary') {
74    $theme_method = variable_get('taxonomy_theme_method', 0);      if ($op == 'delete') {
75    // perform taxonomy-based theme selection        db_query('DELETE FROM {themekey_properties} WHERE property = \'vid\' AND value = \'%s\'', $array['vid']);
   if ($theme_method) {  
     require_once (drupal_get_path('module', 'taxonomy_theme').'/taxonomy_theme_taxonomy.inc');  
     _taxonomy_theme_select_forum($theme_method, $custom_theme, $default_theme, $uri);  
     switch ($theme_method) {  
       case TAXOTHEME_TERM:  
         _taxonomy_theme_select_term($theme_method, $custom_theme, $default_theme, $uri);  
         break;  
       case TAXOTHEME_VOCAB:  
         _taxonomy_theme_select_vocabulary($theme_method, $custom_theme, $default_theme, $uri);  
         break;  
       case TAXOTHEME_ALLTAXO:  
         _taxonomy_theme_select_alltaxonomy($theme_method, $custom_theme, $default_theme, $uri);  
         break;  
       case TAXOTHEME_NODETYPE:  
         _taxonomy_theme_select_nodetype($theme_method, $custom_theme, $default_theme, $uri);  
         break;  
       default:  
         // TAXOTHEME_SKIP or nothing to do  
76      }      }
77        _themekey_properties_resort('vid');
78    }    }
79    // perform extended (path-based) theme selection    else if ($type == 'term') {
80    if (variable_get('taxonomy_theme_extended_enable', 0)) {      if ($op == 'delete') {
81      require_once (drupal_get_path('module', 'taxonomy_theme').'/taxonomy_theme_pathes.inc');        db_query('DELETE FROM {themekey_properties} WHERE property = \'tid\' AND value = \'%s\'', $array['tid']);
82      _taxonomy_theme_select_pathes($custom_theme, $uri);      }
83    }      _themekey_properties_resort('tid');
   // only apply for theme != default theme (users can have own default theme)  
   if (isset($custom_theme) && ($custom_theme != $default_theme)) {  
     init_theme();  
84    }    }
85  }  }
   
 ?>  

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

  ViewVC Help
Powered by ViewVC 1.1.2