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

Diff of /contributions/modules/content_slider/content_slider.module

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

revision 1.1.2.5, Mon Dec 22 13:16:33 2008 UTC revision 1.1.2.6, Sat Jan 10 20:27:49 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: content_slider.module,v 1.1.2.4 2008/12/14 19:24:45 ebizondrupalservices Exp $  // $Id: content_slider.module,v 1.1.2.3 2008/12/14 14:24:01 ebizondrupalservices Exp $
3    
4    
5  /**  /**
# Line 28  function content_slider_perm() { Line 28  function content_slider_perm() {
28    return array('access content_slider', 'administer content_slider');    return array('access content_slider', 'administer content_slider');
29  }  }
30    
31  function content_slider_menu() {  function content_slider_menu($may_cache) {
32    $items = array();    $items = array();
33      if ($may_cache) {
34      $items['admin/settings/content_slider'] = array(      $items[] = array(
35      'title' => 'Content Slider',        'path' => 'admin/settings/content_slider',
36      'description' => t('Setting Content Slider.'),        'title' => 'Content Slider',
37      'page callback' => 'drupal_get_form',        'description' => t('Setting Content Slider.'),
38      'page arguments' => array('content_slider_admin_settings'),        'callback' => 'drupal_get_form',
39      'access arguments' => array('administer site configuration'),        'callback arguments' => array('content_slider_admin_settings'),
40    );        'access' => user_access('administer content_slider'),
41     $items[] = array(        'type' => MENU_NORMAL_ITEM,
42     'path' => 'content_slider/list/'. arg(2),      );
43     'title' => t('Content Slider'),  
44     'page callback' => 'content_slider_page_list',      $items[] = array(
45     'page arguments' => array(arg(2)),        'path' => 'content_slider/list/'. arg(2),
46     'access arguments' => array('access content_slider'),        'title' => t('Content Slider'),
47     'type' => MENU_CALLBACK,        'callback' => 'content_slider_page_list',
48     );        'callback arguments' => array(arg(2)),
49          'access' => user_access('access content_slider'),
50          'type' => MENU_CALLBACK,
51        );
52      }
53    return $items;    return $items;
54  }  }
55    
# Line 108  function content_slider_admin_settings() Line 112  function content_slider_admin_settings()
112    $form['content_slider_source']['content_slider_source_3'] = array(    $form['content_slider_source']['content_slider_source_3'] = array(
113      '#type' => 'textfield',      '#type' => 'textfield',
114      '#title' => t('Content type for Slider 3'),      '#title' => t('Content type for Slider 3'),
115      '#default_value' => variable_get('content_slider_source_3', ''),      '#default_value' => variable_get('content_slider_source_3', 'featured'),
116    );    );
117    
118    return system_settings_form($form);    return system_settings_form($form);
# Line 124  function content_slider_block($op = 'lis Line 128  function content_slider_block($op = 'lis
128    $content_slider_direction = variable_get("content_slider_direction", 'leftright');    $content_slider_direction = variable_get("content_slider_direction", 'leftright');
129    
130    $content_slider_source_1 = variable_get("content_slider_source_1", "page");    $content_slider_source_1 = variable_get("content_slider_source_1", "page");
131    $content_slider_source_2 = variable_get("content_slider_source_2", "");    $content_slider_source_2 = variable_get("content_slider_source_2", "story");
132    $content_slider_source_3 = variable_get("content_slider_source_3", "");    $content_slider_source_3 = variable_get("content_slider_source_3", "featured");
133    
134    global $base_url;    global $base_url;
135    $ajax_base_path = $base_url;    $ajax_base_path = $base_url;
# Line 155  function content_slider_block($op = 'lis Line 159  function content_slider_block($op = 'lis
159      //drupal_add_js($output_head,'inline');      //drupal_add_js($output_head,'inline');
160    
161      $slider_id = $delta + 1;      $slider_id = $delta + 1;
162      switch ($delta) {       switch ($delta) {
163        case 0:        case 0:
164          $content_type = $content_slider_source_1;          $content_type = $content_slider_source_1;
165            $block['subject'] = 'Content Slider 1';
166            $block['content'] = outbody_of_block($content_type,$delta);
167          break;          break;
168    
169        case 1:        case 1:
170          $content_type = $content_slider_source_2;          $content_type = $content_slider_source_2;
171            $block['subject'] = 'Content Slider 2';
172            $block['content'] = outbody_of_block($content_type,$delta);
173    
174          break;          break;
175    
176        case 2:        case 2:
177          $content_type = $content_slider_source_3;          $content_type = $content_slider_source_3;
178            $block['subject'] = 'Content Slider 3';
179            $block['content'] = outbody_of_block($content_type,$delta);
180    
181          break;          break;
182      }      }
183        return $block;
184    
185      $output_body = '';      }
186      $sql  = " SELECT n.nid, teaser FROM {node} n INNER JOIN {node_revisions} r ON n.nid=r.nid "." WHERE n.status=1 AND n.type='$content_type' ORDER BY n.created  LIMIT 5";  }
187    function outbody_of_block($content_type,$delta)
188    {
189     $output_body = '';
190        $sql  = " SELECT n.nid, teaser FROM {node} n INNER JOIN {node_revisions} r ON n.nid=r.nid "." WHERE n.status=1 AND n.type='".$content_type."' ORDER BY n.changed DESC LIMIT 5";
191      $results     = db_query($sql);      $results     = db_query($sql);
192    
193      $output_body .= '<div id="slider1" class="sliderwrapper">'."\n";      $output_body .= '<div id="slider'.$delta.'" class="sliderwrapper">'."\n";
194      while ($data = db_fetch_object($results)) {      while ($data = db_fetch_object($results)) {
195        $slider_nid = $data->nid;        $slider_nid = $data->nid;
196        $output_body .= '<div class="contentdiv">'."\n";        $output_body .= '<div class="contentdiv">'."\n";
197        $output_body .= "<a href='$base_url/node/$slider_nid'>". node_view(node_load($data->nid), 1) ."</a>";        $output_body .= "<a href='".$base_url."/node/".$slider_nid."'>". node_view(node_load($data->nid), 1) ."</a>";
198        if ($slider_nid == 1) {        if ($slider_nid == 1) {
199          $output_body .= '<p></p><a href="javascript:featuredcontentslider.jumpTo(\'slider1\', 3)">';          $output_body .= '<p></p><a href="javascript:featuredcontentslider.jumpTo(\'slider1\', 3)">';
200        }        }
201        $output_body .= '</div>';        $output_body .= '</div>';
202      }      }
203      $output_body .= '</div>';      $output_body .= '</div>';
204      $output_body .= '<div id="paginate-slider1" class="pagination">'."\n";      $output_body .= '<div id="paginate-slider'.$delta.'" class="pagination">'."\n";
205      $output_body .= '</div>';      $output_body .= '</div>';
206    
207      $output_body .= '<script type="text/javascript">';      $output_body .= '<script type="text/javascript">';
208    
209      $output_body .= 'featuredcontentslider.init({'."\n";      $output_body .= 'featuredcontentslider.init({'."\n";
210      $output_body .= 'id: "slider1",//id of main slider DIV'."\n";      $output_body .= 'id: "slider'.$delta.'",//id of main slider DIV'."\n";
211      $output_body .= 'contentsource: ["inline", ""],  //Valid values: ["inline", ""] or ["ajax", "path_to_file"]'."\n";      $output_body .= 'contentsource: ["inline", ""],  //Valid values: ["inline", ""] or ["ajax", "path_to_file"]'."\n";
212      $output_body .= 'toc: "#increment",  //Valid values: "#increment", "markup", ["label1", "label2", etc]'."\n";      $output_body .= 'toc: "#increment",  //Valid values: "#increment", "markup", ["label1", "label2", etc]'."\n";
213      $output_body .= 'nextprev: ["Previous", "Next"],  //labels for "prev" and "next" links. Set to "" to hide.'."\n";      $output_body .= 'nextprev: ["Previous", "Next"],  //labels for "prev" and "next" links. Set to "" to hide.'."\n";
# Line 204  function content_slider_block($op = 'lis Line 221  function content_slider_block($op = 'lis
221      $output_body .= '})';      $output_body .= '})';
222    
223      $output_body .= '</script>';      $output_body .= '</script>';
224         return  $output_body;
225    
226      //$output_body .= '</div>';      //$output_body .= '</div>';
   
   
     $block['subject'] = 'Content Slider 1';  
     $block['content'] = $output_body;  
   
   
     return $block;  
   }  
227  }  }
228    
229  function content_slider_page_list($i) {  function content_slider_page_list($i) {
230    $content_slider_item = variable_get("content_slider_item", 10);    $content_slider_item = variable_get("content_slider_item", 10);
231    
232    $dse_news_total = db_query(" SELECT count(*) AS total FROM {node} n WHERE n.type='slider$i' AND n.status=1");    $dse_news_total = db_query(" SELECT count(*) AS total FROM {node} n WHERE n.type='slider".$i."' AND n.status=1");
233    $row_news       = db_fetch_object($dse_news_total);    $row_news       = db_fetch_object($dse_news_total);
234    $news_total     = $row_news->total;    $news_total     = $row_news->total;
235    $sql_counts     = "SELECT $news_total";    $sql_counts     = "SELECT $news_total";

Legend:
Removed from v.1.1.2.5  
changed lines
  Added in v.1.1.2.6

  ViewVC Help
Powered by ViewVC 1.1.2