| 1 |
<?php |
<?php |
| 2 |
//$Id: video_image.module,v 1.15.2.5 2009/07/25 03:15:42 heshanmw Exp $ |
//$Id: video_image.module,v 1.15.2.6 2009/10/01 15:00:59 heshanmw Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Enable image support for video module. |
* Enable image support for video module. |
| 159 |
} |
} |
| 160 |
|
|
| 161 |
$auto_thumbable = video_image_is_autothumbable($node); |
$auto_thumbable = video_image_is_autothumbable($node); |
| 162 |
|
//echo ''.$auto_thumbable; |
| 163 |
//GMM: fix permission misspelling |
//GMM: fix permission misspelling |
| 164 |
$perm=video_image_perm(); |
// TODO : set correct permission |
| 165 |
if(!$auto_thumbable || user_access($perm[OVERRIDE_IMAGE])) { // let's be sure that image directories are ready |
$perm = video_image_perm(); |
| 166 |
|
if(!$auto_thumbable || user_access($perm[OVERRIDE_IMAGE])) {// let's be sure that image directories are ready |
| 167 |
if (function_exists('_image_check_settings')) { |
if (function_exists('_image_check_settings')) { |
| 168 |
_image_check_settings(); |
_image_check_settings(); |
| 169 |
} |
} |
| 170 |
// needed for uploading |
// needed for uploading |
| 171 |
$form['#attributes'] = array("enctype" => "multipart/form-data"); |
$form['#attributes'] = array( |
| 172 |
|
"enctype" => "multipart/form-data" |
| 173 |
|
); |
| 174 |
|
|
| 175 |
$form['image'] = array('#type' => 'fieldset', '#title' => t('Image thumbnails'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17, '#description' => t('Upload an image to be used as the thumbnail for this video.')); |
$form['image'] = array( |
| 176 |
|
'#type' => 'fieldset', |
| 177 |
|
'#title' => t('Image thumbnails'), |
| 178 |
|
'#collapsible' => TRUE, |
| 179 |
|
'#collapsed' => TRUE, |
| 180 |
|
'#weight' => -17, |
| 181 |
|
'#description' => t('Upload an image to be used as the thumbnail for this video.') |
| 182 |
|
); |
| 183 |
|
|
| 184 |
$form['image']['image'] = array('#type' => 'file', '#title' => t('Image')); |
$form['image']['image'] = array( |
| 185 |
|
'#type' => 'file', |
| 186 |
|
'#title' => t('Image') |
| 187 |
|
); |
| 188 |
} |
} |
| 189 |
if ($node->nid && $auto_thumbable) { |
if ($node->nid && $auto_thumbable) { |
| 190 |
$form['regenerate_thumbnail'] = array('#type' => 'checkbox', '#title' => t('Auto regenerate thumbnail'), '#default_value' => 0); |
$form['regenerate_thumbnail'] = array( |
| 191 |
|
'#type' => 'checkbox', |
| 192 |
|
'#title' => t('Auto regenerate thumbnail'), |
| 193 |
|
'#default_value' => 0 |
| 194 |
|
); |
| 195 |
} |
} |
| 196 |
} |
} |
| 197 |
} |
} |
| 216 |
|
|
| 217 |
case 'presave': |
case 'presave': |
| 218 |
//exit; |
//exit; |
| 219 |
_video_image_submit($node); |
_video_image_presave($node); |
| 220 |
break; |
break; |
| 221 |
|
|
| 222 |
case 'view': |
case 'view': |
| 271 |
|
|
| 272 |
function _video_image_prepare(&$node) { |
function _video_image_prepare(&$node) { |
| 273 |
// let's check that we have a valid image |
// let's check that we have a valid image |
|
//print_r($node); |
|
|
//exit; |
|
| 274 |
if (count($_POST)) { |
if (count($_POST)) { |
| 275 |
|
$validators = array( |
| 276 |
$validators = array( |
'file_validate_is_image' => array() |
| 277 |
'file_validate_is_image' => array() |
); |
|
); |
|
| 278 |
|
|
| 279 |
$field_name = file_save_upload('image', $validators); |
$field_name = file_save_upload('image', $validators); |
| 280 |
if (!$field_name && video_image_is_autothumbable($node)) { |
if (!$field_name && video_image_is_autothumbable($node)) { |
| 294 |
} |
} |
| 295 |
} |
} |
| 296 |
|
|
| 297 |
function _video_image_submit(&$node) { |
function _video_image_presave(&$node) { |
| 298 |
//print_r($node); |
//print_r($node); |
| 299 |
//exit; |
//exit; |
| 300 |
// ############# PREPARE ####################### |
// ############# PREPARE ####################### |
| 301 |
// ------------- MOVED ------------------------- |
// ------------- MOVED ------------------------- |
| 302 |
if (count($_POST)) { |
if (count($_POST)) { |
| 303 |
|
$validators = array( |
| 304 |
$validators = array( |
'file_validate_is_image' => array() |
| 305 |
'file_validate_is_image' => array() |
); |
|
); |
|
| 306 |
|
|
| 307 |
$field_name = file_save_upload('image', $validators); |
$field_name = file_save_upload('image', $validators); |
| 308 |
if (!$field_name && video_image_is_autothumbable($node)) { |
if (!$field_name && video_image_is_autothumbable($node)) { |
| 376 |
//GMM: Fix to use the proper variable to trigger current Image module to rebuild derivative images |
//GMM: Fix to use the proper variable to trigger current Image module to rebuild derivative images |
| 377 |
// Tested against Image 6.x-1.0-aplha4 |
// Tested against Image 6.x-1.0-aplha4 |
| 378 |
// $oldimage->new_image = 1; |
// $oldimage->new_image = 1; |
| 379 |
$oldimage->new_file = true; |
$oldimage->new_file = true; |
| 380 |
node_save($oldimage); |
node_save($oldimage); |
| 381 |
$node->iid = $oldimage->nid; |
$node->iid = $oldimage->nid; |
| 382 |
$node->serial_data['iid'] = $node->iid; |
$node->serial_data['iid'] = $node->iid; |