/[drupal]/contributions/modules/taxonomy_dss/taxonomy_dss_newcontent/taxonomy_dss_newcontent.module
ViewVC logotype

Diff of /contributions/modules/taxonomy_dss/taxonomy_dss_newcontent/taxonomy_dss_newcontent.module

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

revision 1.1, Wed Jan 9 18:25:48 2008 UTC revision 1.1.2.1, Wed Jan 23 20:38:59 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: taxonomy_dss_newcontent.module,v 1.1 2008/01/09 18:25:48 moonray Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 50  function taxonomy_dss_newcontent_form_al Line 50  function taxonomy_dss_newcontent_form_al
50        );        );
51        break;        break;
52    
53      case 'term_node_form':      case 'termset_node_form':
54        if (arg(0) == 'taxonomy' && arg(1) == 'term' && (arg(3) == 'add' || arg(3) == 'edit')) {        $node = $form['#node'];
55    
56          $termset = taxonomy_dss_load(arg(2));        $form['newcontent_options'] = array(
57            '#type' => 'fieldset',
58          $form['newcontent_options'] = array(          '#title' => t('New content listing options'),
59            '#type' => 'fieldset',          '#collapsible' => TRUE,
60            '#title' => t('New content listing options'),          '#collapsed' => FALSE,
61            '#collapsible' => TRUE,          '#weight' => -3,
62            '#collapsed' => FALSE,        );
63            '#weight' => -3,        $form['newcontent_options']['newcontent_hidden'] = array(
64          );          '#type' => 'checkbox',
65          $form['newcontent_options']['newcontent_hidden'] = array(          '#title' => t('Show new content'),
66            '#type' => 'checkbox',          '#default_value' => !$node->termset->serial_data['newcontent_hidden'],
67            '#title' => t('Show new content'),          '#description' => t('List new content from this term\'s sub-categories.'),
68            '#default_value' => isset($node->newcontent_hidden) ? !$node->newcontent_hidden : !$termset->serial_data['newcontent_hidden'],          '#tree' => TRUE,
69            '#description' => t('List new content from this term\'s sub-categories.'),          '#parents' => array('termset', 'serial_data', 'newcontent_hidden'),
70          );        );
71          $form['newcontent_options']['newcontent_from_anywhere'] = array(        $form['newcontent_options']['newcontent_from_anywhere'] = array(
72            '#type' => 'checkbox',          '#type' => 'checkbox',
73            '#title' => t('Use any new content'),          '#title' => t('Use any new content'),
74            '#default_value' => isset($node->newcontent_from_anywhere) ? $node->newcontent_from_anywhere : $termset->serial_data['newcontent_from_anywhere'],          '#default_value' => $node->termset->serial_data['newcontent_from_anywhere'],
75            '#description' => t('New content can come from any term. Essentially list any new content on the site.'),          '#description' => t('New content can come from any term. Essentially list any new content on the site.'),
76          );          '#tree' => TRUE,
77          $form['newcontent_options']['newcontent_count'] = array(          '#parents' => array('termset', 'serial_data', 'newcontent_from_anywhere'),
78            '#type' => 'textfield',        );
79            '#title' => t('Amount of new nodes'),        $form['newcontent_options']['newcontent_count'] = array(
80            '#default_value' => isset($node->newcontent_count) ? $node->newcontent_count : $termset->serial_data['newcontent_count'],          '#type' => 'textfield',
81            '#description' => t('The amount of new nodes to list from this term\'s sub-categories.'),          '#title' => t('Amount of new nodes'),
82          );          '#default_value' => $node->termset->serial_data['newcontent_count'],
83          $form['newcontent_options']['newcontent_title'] = array(          '#description' => t('The amount of new nodes to list from this term\'s sub-categories.'),
84            '#type' => 'textfield',          '#tree' => TRUE,
85            '#title' => t('Title'),          '#parents' => array('termset', 'serial_data', 'newcontent_count'),
86            '#default_value' => isset($node->newcontent_title) ? $node->newcontent_title : $termset->serial_data['newcontent_title'],        );
87            '#description' => t('This title appears at the top of the new content section. Leave blank for no title.'),        $form['newcontent_options']['newcontent_title'] = array(
88          );          '#type' => 'textfield',
89            '#title' => t('Title'),
90        }          '#default_value' => $node->termset->serial_data['newcontent_title'],
91            '#description' => t('This title appears at the top of the new content section. Leave blank for no title.'),
92            '#tree' => TRUE,
93            '#parents' => array('termset', 'serial_data', 'newcontent_title'),
94          );
95    
96        break;        break;
97    }    }
98  }  }
# Line 99  function taxonomy_dss_newcontent_form_al Line 104  function taxonomy_dss_newcontent_form_al
104   *      ->terms   *      ->terms
105   *      ->content   *      ->content
106   */   */
107  function taxonomy_dss_newcontent_taxonomy_dss(&$termset, $op, $node = NULL) {  function taxonomy_dss_newcontent_taxonomy_dss(&$node, $op, &$content) {
108    switch ($op) {    switch ($op) {
109      case 'load':      case 'load':
110        // Set defaults        // Set defaults
111        if (!isset($termset->serial_data['newcontent_hidden'])) {        if (!isset($node->termset->serial_data['newcontent_hidden'])) {
112          $termset->serial_data['newcontent_hidden'] = variable_get('taxonomy_dss_newcontent_hidden', TAXONOMY_DSS_NEWCONTENT_DEFAULT_HIDDEN);          $node->termset->serial_data['newcontent_hidden'] = variable_get('taxonomy_dss_newcontent_hidden', TAXONOMY_DSS_NEWCONTENT_DEFAULT_HIDDEN);
113        }        }
114        if (!isset($termset->serial_data['newcontent_from_anywhere'])) {        if (!isset($node->termset->serial_data['newcontent_from_anywhere'])) {
115          $termset->serial_data['newcontent_from_anywhere'] = variable_get('taxonomy_dss_newcontent_from_anywhere', TAXONOMY_DSS_NEWCONTENT_DEFAULT_FROM_ANYWHERE);          $node->termset->serial_data['newcontent_from_anywhere'] = variable_get('taxonomy_dss_newcontent_from_anywhere', TAXONOMY_DSS_NEWCONTENT_DEFAULT_FROM_ANYWHERE);
116        }        }
117        if (!isset($termset->serial_data['newcontent_count'])) {        if (!isset($node->termset->serial_data['newcontent_count'])) {
118          $termset->serial_data['newcontent_count'] = variable_get('taxonomy_dss_newcontent_count', TAXONOMY_DSS_NEWCONTENT_DEFAULT_COUNT);          $node->termset->serial_data['newcontent_count'] = variable_get('taxonomy_dss_newcontent_count', TAXONOMY_DSS_NEWCONTENT_DEFAULT_COUNT);
119        }        }
120        if (!isset($termset->serial_data['newcontent_title'])) {        if (!isset($node->termset->serial_data['newcontent_title'])) {
121          $termset->serial_data['newcontent_title'] = variable_get('taxonomy_dss_newcontent_title', t('New Content'));          $node->termset->serial_data['newcontent_title'] = variable_get('taxonomy_dss_newcontent_title', t('New Content'));
122        }        }
123        break;        break;
124    
125      case 'submit':      case 'submit':
126        $termset->serial_data['newcontent_hidden'] = !$node->newcontent_hidden;        $node->termset->serial_data['newcontent_hidden'] = $node->termset->serial_data['newcontent_hidden'] ? 0 : 1;
       $termset->serial_data['newcontent_from_anywhere'] = $node->newcontent_from_anywhere;  
       $termset->serial_data['newcontent_count'] = $node->newcontent_count;  
       $termset->serial_data['newcontent_title'] = $node->newcontent_title;  
   
127        break;        break;
128    
129      case 'page':      case 'build content':
130        if (!$termset->serial_data['newcontent_hidden']) { // need to call variable that manages showing newcontent on a term page        $termset = $node;
131    
132          // Need to call variable that manages showing newcontent on a term page
133          if (!$termset->serial_data['newcontent_hidden']) {
134            $terms = taxonomy_dss_terms_parse_string($termset->tids);
135    
136          if ($termset->serial_data['newcontent_from_anywhere']) {          if ($termset->serial_data['newcontent_from_anywhere']) {
137            $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), $termset->serial_data['newcontent_count']);            $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), $termset->serial_data['newcontent_count']);
138            $newcontent = _taxonomy_dss_get_tree_nodes($termset->terms['tids'], $result);            $newcontent = _taxonomy_dss_get_tree_nodes($terms['tids'], $result);
139          }          }
140          else {          else {
141            $result = taxonomy_dss_select_nodes($termset->terms['tids'], $termset->terms['operator'], 100, FALSE, 'n.created DESC', FALSE, TRUE, $termset->serial_data['newcontent_count']);            $result = taxonomy_dss_select_nodes($terms['tids'], $terms['operator'], 100, FALSE, 'n.created DESC', FALSE, TRUE, $termset->serial_data['newcontent_count']);
142            $newcontent = _taxonomy_dss_get_tree_nodes($termset->terms['tids'], $result);            $newcontent = _taxonomy_dss_get_tree_nodes($terms['tids'], $result);
143          }          }
144    
145          $termset->content['newcontent'] = array(          $content['newcontent'] = array(
146            '#value' => theme('taxonomy_dss_newcontent', $termset, $newcontent),            '#value' => theme('taxonomy_dss_newcontent', $termset, $newcontent),
147            '#weight' => 1,            '#weight' => 1,
148          );          );
   
         return $termset;  
149        }        }
150        break;        break;
   
     case 'feed':  
       return $termset;  
       break;  
151    }    }
152  }  }
153    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2