| 1 |
<?php
|
| 2 |
// $Id: content_glider.module,v 1.5 2009/03/28 15:20:02 thenicespider Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Display content and image in Slide show mode using jQuery.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_help().
|
| 11 |
*/
|
| 12 |
function content_glider_help($section) {
|
| 13 |
switch ($section) {
|
| 14 |
case 'admin/help#content_glider':
|
| 15 |
$output = "The content_glider module: Display content and image in Slide show mode using jQuery.";
|
| 16 |
return $output;
|
| 17 |
case 'admin/modules#description':
|
| 18 |
return 'The content_glider module: Display content and image in Slide show mode using jQuery.';
|
| 19 |
}
|
| 20 |
}
|
| 21 |
|
| 22 |
/**
|
| 23 |
* Implementation of hook_perm
|
| 24 |
*/
|
| 25 |
function content_glider_perm() {
|
| 26 |
return array('access content_glider', 'administer content_glider');
|
| 27 |
}
|
| 28 |
|
| 29 |
/*
|
| 30 |
$items['admin/settings/counter'] = array(
|
| 31 |
'title' => 'Counter settings',
|
| 32 |
'description' => 'Show Site Counter, Client IP, and Unique Visitor.',
|
| 33 |
'access arguments' => array('administer counter'),
|
| 34 |
'page callback' => 'drupal_get_form',
|
| 35 |
'page arguments' => array('counter_admin_settings'),
|
| 36 |
'type' => MENU_NORMAL_ITEM,
|
| 37 |
'file' => 'counter.settings.inc',
|
| 38 |
);
|
| 39 |
*/
|
| 40 |
|
| 41 |
function content_glider_menu() {
|
| 42 |
|
| 43 |
$items = array();
|
| 44 |
|
| 45 |
$items['admin/settings/content_glider'] = array(
|
| 46 |
'title' => 'Content Glider',
|
| 47 |
'description' => t('Setting Content Glider.'),
|
| 48 |
'access arguments' => array('administer content_glider'),
|
| 49 |
'page callback' => 'drupal_get_form',
|
| 50 |
'page arguments' => array('content_glider_admin_settings'),
|
| 51 |
'type' => MENU_NORMAL_ITEM);
|
| 52 |
|
| 53 |
return $items;
|
| 54 |
}
|
| 55 |
|
| 56 |
function content_glider_admin_settings() {
|
| 57 |
|
| 58 |
// only administrators can access this function
|
| 59 |
|
| 60 |
// Generate the form - settings applying to all patterns first
|
| 61 |
$form['content_glider_settings'] = array(
|
| 62 |
'#type' => 'fieldset',
|
| 63 |
'#weight' => -20,
|
| 64 |
'#title' => t('Basic settings'),
|
| 65 |
'#collapsible' => TRUE,
|
| 66 |
'#collapsed' => FALSE
|
| 67 |
);
|
| 68 |
$form['content_glider_settings']['content_glider_auto'] = array(
|
| 69 |
'#type' => 'checkbox',
|
| 70 |
'#title' => t('Auto rotate contents'),
|
| 71 |
'#default_value' => variable_get('content_glider_auto', 1),
|
| 72 |
'#description' => t("Display content without mouse click."),
|
| 73 |
'#maxlength' => '1', '#size' => '1');
|
| 74 |
|
| 75 |
$form['content_glider_settings']['content_glider_speed'] = array(
|
| 76 |
'#type' => 'textfield',
|
| 77 |
'#title' => t('Glide animation duration (in milliseconds)'),
|
| 78 |
'#default_value' => variable_get('content_glider_speed', 1000),
|
| 79 |
);
|
| 80 |
$form['content_glider_settings']['content_glider_direction'] = array(
|
| 81 |
'#type' => 'select',
|
| 82 |
'#title' => t('Set direction of glide'),
|
| 83 |
'#default_value' => variable_get('content_glider_direction', 0),
|
| 84 |
'#options' => array('up to down', 'down to up', 'left to right', 'right to left'),
|
| 85 |
'#description' => 'Select the animation direction'
|
| 86 |
);
|
| 87 |
$form['content_glider_settings']['content_glider_count'] = array(
|
| 88 |
'#type' => 'textfield',
|
| 89 |
'#title' => t('Number of contents to glide'),
|
| 90 |
'#default_value' => variable_get('content_glider_count', 5),
|
| 91 |
);
|
| 92 |
|
| 93 |
//$output_body .= 'direction: "downup", //set direction of glide: "updown", "downup", "leftright", or "rightleft"'
|
| 94 |
|
| 95 |
$form['content_glider_source'] = array(
|
| 96 |
'#type' => 'fieldset',
|
| 97 |
'#weight' => -20,
|
| 98 |
'#title' => t('Glider content source (based on Drupal content-type)'),
|
| 99 |
'#collapsible' => TRUE,
|
| 100 |
'#collapsed' => FALSE
|
| 101 |
);
|
| 102 |
$form['content_glider_source']['content_glider_source_1'] = array(
|
| 103 |
'#type' => 'textfield',
|
| 104 |
'#title' => t('Content type for Glider 1'),
|
| 105 |
'#default_value' => variable_get('content_glider_source_1', 'page'),
|
| 106 |
);
|
| 107 |
$form['content_glider_source']['content_glider_source_2'] = array(
|
| 108 |
'#type' => 'textfield',
|
| 109 |
'#title' => t('Content type for Glider 2'),
|
| 110 |
'#default_value' => variable_get('content_glider_source_2', ''),
|
| 111 |
);
|
| 112 |
$form['content_glider_source']['content_glider_source_3'] = array(
|
| 113 |
'#type' => 'textfield',
|
| 114 |
'#title' => t('Content type for Glider 3'),
|
| 115 |
'#default_value' => variable_get('content_glider_source_3', ''),
|
| 116 |
);
|
| 117 |
return system_settings_form($form);
|
| 118 |
}
|
| 119 |
|
| 120 |
/**
|
| 121 |
* Implementation of hook_block().
|
| 122 |
*
|
| 123 |
*/
|
| 124 |
function content_glider_block($op = 'list', $delta = 0) {
|
| 125 |
$content_glider_auto = variable_get("content_glider_auto", 1);
|
| 126 |
$content_glider_speed = variable_get("content_glider_speed", 1000);
|
| 127 |
$content_glider_count = variable_get("content_glider_count", 5);
|
| 128 |
|
| 129 |
$content_glider_direction = variable_get("content_glider_direction", 0);
|
| 130 |
|
| 131 |
if ($content_glider_direction==0) { $content_glider_direction_value = 'updown'; }
|
| 132 |
if ($content_glider_direction==1) { $content_glider_direction_value = 'downup'; }
|
| 133 |
if ($content_glider_direction==2) { $content_glider_direction_value = 'leftright'; }
|
| 134 |
if ($content_glider_direction==3) { $content_glider_direction_value = 'rightleft'; }
|
| 135 |
|
| 136 |
$content_glider_source_1 = variable_get("content_glider_source_1", "page");
|
| 137 |
$content_glider_source_2 = variable_get("content_glider_source_2", "");
|
| 138 |
$content_glider_source_3 = variable_get("content_glider_source_3", "");
|
| 139 |
|
| 140 |
global $base_url;
|
| 141 |
$ajax_base_path = $base_url;
|
| 142 |
|
| 143 |
if ($op == 'list')
|
| 144 |
{
|
| 145 |
$blocks[0]['info'] = 'Content Glider 1';
|
| 146 |
$blocks[1]['info'] = 'Content Glider 2';
|
| 147 |
$blocks[2]['info'] = 'Content Glider 3';
|
| 148 |
return $blocks;
|
| 149 |
}
|
| 150 |
|
| 151 |
if ($op == 'view') {
|
| 152 |
|
| 153 |
switch($delta) {
|
| 154 |
case 0: $content_type = $content_glider_source_1; break;
|
| 155 |
case 1: $content_type = $content_glider_source_2; break;
|
| 156 |
case 2: $content_type = $content_glider_source_3; break;
|
| 157 |
}
|
| 158 |
|
| 159 |
$sql = " SELECT n.nid, n.title, r.teaser FROM {node} n INNER JOIN {node_revisions} r ON n.nid=r.nid "
|
| 160 |
." WHERE n.status=1 AND n.type='%s' ORDER BY n.created DESC LIMIT %s";
|
| 161 |
$results = db_query($sql, $content_type, $content_glider_count);
|
| 162 |
|
| 163 |
if (!db_result($results)) {
|
| 164 |
return;
|
| 165 |
}
|
| 166 |
|
| 167 |
drupal_add_css(drupal_get_path('module', 'content_glider') . '/featuredcontentglider.css');
|
| 168 |
drupal_add_js(drupal_get_path('module', 'content_glider'). '/featuredcontentglider.js', 'module');
|
| 169 |
drupal_add_js(drupal_get_path('module', 'content_glider'). '/jquery-1.2.2.pack.js', 'module');
|
| 170 |
//Text
|
| 171 |
$output_head =''."\n";
|
| 172 |
$output_head .= '/***********************************************'."\n";
|
| 173 |
$output_head .= '* Featured Content Glider script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)'."\n";
|
| 174 |
$output_head .= '* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts'."\n";
|
| 175 |
$output_head .= '* This notice must stay intact for legal use'."\n";
|
| 176 |
$output_head .= '***********************************************/'."\n";
|
| 177 |
drupal_add_js($output_head,'inline');
|
| 178 |
|
| 179 |
$glider_id = $delta+1;
|
| 180 |
|
| 181 |
$output_body = '';
|
| 182 |
$output_body .= '<script type="text/javascript">'."\n";
|
| 183 |
|
| 184 |
$output_body .= 'featuredcontentglider.init({'."\n";
|
| 185 |
$output_body .= 'gliderid: "Glider'.$glider_id.'", //ID of main glider container'."\n";
|
| 186 |
$output_body .= 'contentclass: "glidecontent", //Shared CSS class name of each glider content'."\n";
|
| 187 |
$output_body .= 'togglerid: "p-select", //ID of toggler container'."\n";
|
| 188 |
$output_body .= 'remotecontent: "", //Get gliding contents from external file on server? "filename" or "" to disable'."\n";
|
| 189 |
$output_body .= 'selected: 0, //Default selected content index (0=1st)'."\n";
|
| 190 |
$output_body .= 'persiststate: false, //Remember last content shown within browser session (true/false)?'."\n";
|
| 191 |
$output_body .= 'speed: '.$content_glider_speed.', //Glide animation duration (in milliseconds)'."\n";
|
| 192 |
$output_body .= 'direction: "'.$content_glider_direction_value.'", //set direction of glide: "updown", "downup", "leftright", or "rightleft"'."\n";
|
| 193 |
if ($content_glider_auto) { $auto="true"; } else { $auto="false"; }
|
| 194 |
$output_body .= 'autorotate: '.$auto.', //Auto rotate contents (true/false)?'."\n";
|
| 195 |
$output_body .= 'autorotateconfig: [3000, 2] //if auto rotate enabled, set [milliseconds_btw_rotations, cycles_before_stopping]'."\n";
|
| 196 |
$output_body .= '})'."\n";
|
| 197 |
|
| 198 |
$output_body .= '</script>';
|
| 199 |
|
| 200 |
$output_body .= '<div id="Glider'.$glider_id.'" class="glidecontentwrapper">';
|
| 201 |
|
| 202 |
$results = db_query($sql, $content_type, $content_glider_count);
|
| 203 |
while ($data = db_fetch_object($results)) {
|
| 204 |
if ($data->teaser != '') {
|
| 205 |
$glider_nid = $data->nid;
|
| 206 |
$output_body .= '<div class="glidecontent">';
|
| 207 |
$output_body .= "<a href='".url("node/$glider_nid")."'>".$data->teaser ."</a>";
|
| 208 |
$output_body .= '</div>';
|
| 209 |
}
|
| 210 |
}
|
| 211 |
$output_body .= '</div>';
|
| 212 |
|
| 213 |
$output_body .= '<div id="p-select" class="glidecontenttoggler">';
|
| 214 |
$output_body .= '<a href="#" class="prev">Prev</a>';
|
| 215 |
$output_body .= '<a href="#" class="toc">1</a> <a href="#" class="toc">2</a> <a href="#" class="toc">3</a>';
|
| 216 |
$output_body .= '<a href="#" class="toc">4</a> <a href="#" class="toc">5</a> ';
|
| 217 |
$output_body .= '<a href="#" class="next">Next</a>';
|
| 218 |
$output_body .= '</div>';
|
| 219 |
|
| 220 |
$block['subject'] = "Content Glider $glider_id";
|
| 221 |
$block['content'] = $output_body;
|
| 222 |
|
| 223 |
|
| 224 |
return $block;
|
| 225 |
}
|
| 226 |
}
|
| 227 |
|
| 228 |
|
| 229 |
?>
|