| 1 |
<?php
|
| 2 |
// $Id: flex_image.module,v 1.100.2.1 2007/07/26 19:16:45 drumm Exp $
|
| 3 |
|
| 4 |
//hook_menu
|
| 5 |
function flex_image_menu() {
|
| 6 |
$menu = Array();
|
| 7 |
|
| 8 |
$menu['admin/content/flex_image'] = array(
|
| 9 |
'title' => 'Flex Image',
|
| 10 |
'page callback' => 'flex_image_show',
|
| 11 |
'access arguments' => array('administer flex image gallery'),
|
| 12 |
'description' => 'Flex Image incorporates a Flash interface to make managing your photo galleries more intuitive: Search your hard drive for pictures, upload or delete with drag and drop functionality. Also incorporated is a built in web image search.',
|
| 13 |
);
|
| 14 |
|
| 15 |
$menu['flex_image/open'] = array(
|
| 16 |
'title' => 'Flex Image',
|
| 17 |
'page callback' => 'flex_image_open',
|
| 18 |
'type' => MENU_CALLBACK,
|
| 19 |
'access arguments' => array('administer flex image gallery'),
|
| 20 |
);
|
| 21 |
|
| 22 |
$menu['flex_image/unlinked'] = array(
|
| 23 |
'page callback' => 'flex_image_unlinked',
|
| 24 |
'type' => MENU_CALLBACK,
|
| 25 |
'access arguments' => array('administer flex image gallery'),
|
| 26 |
);
|
| 27 |
|
| 28 |
$menu['admin/settings/flex_image'] = array(
|
| 29 |
'title' => 'Flex Image',
|
| 30 |
'page callback' => 'flex_image_settings_show',
|
| 31 |
'access arguments' => array('administer flex image gallery'),
|
| 32 |
);
|
| 33 |
|
| 34 |
$menu['flex_image/folders'] = array(
|
| 35 |
'page callback' => 'flex_image_folders',
|
| 36 |
'type' => MENU_CALLBACK,
|
| 37 |
'access arguments' => array('administer flex image gallery'),
|
| 38 |
);
|
| 39 |
|
| 40 |
$menu['flex_image/settings'] = array(
|
| 41 |
'page callback' => 'flex_image_settings',
|
| 42 |
'type' => MENU_CALLBACK,
|
| 43 |
'access arguments' => array('administer flex image gallery'),
|
| 44 |
);
|
| 45 |
|
| 46 |
$menu['flex_image/new_image'] = array(
|
| 47 |
'page callback' => 'flex_image_new_image',
|
| 48 |
'type' => MENU_CALLBACK,
|
| 49 |
'access arguments' => array('administer flex image gallery'),
|
| 50 |
);
|
| 51 |
|
| 52 |
$menu['flex_image/folders/edit'] = array(
|
| 53 |
'page callback' => 'flex_image_folders_edit',
|
| 54 |
'type' => MENU_CALLBACK,
|
| 55 |
'access arguments' => array('administer flex image gallery'),
|
| 56 |
);
|
| 57 |
|
| 58 |
$menu['flex_image/folders/new'] = array(
|
| 59 |
'page callback' => 'flex_image_folders_new',
|
| 60 |
'type' => MENU_CALLBACK,
|
| 61 |
'access arguments' => array('administer flex image gallery'),
|
| 62 |
);
|
| 63 |
|
| 64 |
$menu['flex_image/folders/delete'] = array(
|
| 65 |
'page callback' => 'flex_image_folders_delete',
|
| 66 |
'type' => MENU_CALLBACK,
|
| 67 |
'access arguments' => array('administer flex image gallery'),
|
| 68 |
);
|
| 69 |
|
| 70 |
$menu['flex_image/sizes'] = array(
|
| 71 |
'page callback' => 'flex_image_folders_sizes',
|
| 72 |
'type' => MENU_CALLBACK,
|
| 73 |
'access arguments' => array('administer flex image gallery'),
|
| 74 |
);
|
| 75 |
|
| 76 |
$menu['flex_image/sizes_save'] = array(
|
| 77 |
'page callback' => 'flex_image_folders_sizes_save',
|
| 78 |
'type' => MENU_CALLBACK,
|
| 79 |
'access arguments' => array('administer flex image gallery'),
|
| 80 |
);
|
| 81 |
|
| 82 |
$menu['flex_image/download_photo'] = array(
|
| 83 |
'page callback' => 'flex_image_download_photo',
|
| 84 |
'type' => MENU_CALLBACK,
|
| 85 |
'access arguments' => array('administer flex image gallery'),
|
| 86 |
);
|
| 87 |
|
| 88 |
$menu['flex_image/move_items'] = array(
|
| 89 |
'page callback' => 'flex_image_move_items',
|
| 90 |
'type' => MENU_CALLBACK,
|
| 91 |
'access arguments' => array('administer flex image gallery'),
|
| 92 |
);
|
| 93 |
|
| 94 |
$menu['flex_image/upload'] = array(
|
| 95 |
'page callback' => 'flex_image_upload',
|
| 96 |
'type' => MENU_CALLBACK,
|
| 97 |
'access callback' => 'flex_image_upload_access',
|
| 98 |
);
|
| 99 |
|
| 100 |
$menu['flex_image/searchgoogle'] = array(
|
| 101 |
'page callback' => 'flex_image_searchgoogle',
|
| 102 |
'type' => MENU_CALLBACK,
|
| 103 |
'access arguments' => array('administer flex image gallery'),
|
| 104 |
);
|
| 105 |
|
| 106 |
$menu['flex_image/image'] = array(
|
| 107 |
'page callback' => 'flex_image_image',
|
| 108 |
'type' => MENU_CALLBACK,
|
| 109 |
'access arguments' => array('administer flex image gallery'),
|
| 110 |
);
|
| 111 |
|
| 112 |
return $menu;
|
| 113 |
}
|
| 114 |
|
| 115 |
//hook_perm
|
| 116 |
function flex_image_perm() {
|
| 117 |
return array('administer flex image gallery');
|
| 118 |
}
|
| 119 |
|
| 120 |
function flex_image_upload_access() {
|
| 121 |
return TRUE;
|
| 122 |
}
|
| 123 |
|
| 124 |
function flex_image_folders() {
|
| 125 |
$xml .= '<folders>';
|
| 126 |
$xml .= flex_image_get_parent_folders();
|
| 127 |
$xml .= '</folders>';
|
| 128 |
|
| 129 |
print $xml;
|
| 130 |
|
| 131 |
drupal_get_messages();
|
| 132 |
|
| 133 |
exit;
|
| 134 |
}
|
| 135 |
|
| 136 |
function flex_image_get_parent_folders() {
|
| 137 |
$var = taxonomy_get_vocabularies('image');
|
| 138 |
|
| 139 |
foreach ($var as $id => $row) {
|
| 140 |
$row->is_parent = TRUE;
|
| 141 |
$xml .= flex_image_folder_info($row);
|
| 142 |
}
|
| 143 |
|
| 144 |
return $xml;
|
| 145 |
}
|
| 146 |
|
| 147 |
function flex_image_get_folders($vid = 0, $parent = 0, $parent_level = '') {
|
| 148 |
$parent_level .= $parent . '-';
|
| 149 |
|
| 150 |
$qr = db_query('select * from {term_data} t LEFT JOIN {term_hierarchy} h ON (t.tid = h.tid) where t.vid=%d AND h.parent=%d', $vid, $parent);
|
| 151 |
|
| 152 |
while ($mrow = db_fetch_object($qr)) {
|
| 153 |
$row = taxonomy_get_term($mrow->tid);
|
| 154 |
$row->parents = taxonomy_get_parents($mrow->tid);
|
| 155 |
|
| 156 |
$xml .= flex_image_folder_info($row, $parent_level);
|
| 157 |
}
|
| 158 |
|
| 159 |
if ($parent > 0) {
|
| 160 |
$tid = Array();
|
| 161 |
$tid[0] = $parent;
|
| 162 |
$nodes = taxonomy_select_nodes($tid);
|
| 163 |
|
| 164 |
while ($row = db_fetch_object($nodes)) {
|
| 165 |
$xml .= flex_image_image_info($row, $parent_level);
|
| 166 |
}
|
| 167 |
}
|
| 168 |
|
| 169 |
return $xml;
|
| 170 |
}
|
| 171 |
|
| 172 |
function flex_image_image_info($frow, $parent_level = '') {
|
| 173 |
$frow = node_load($frow->nid);
|
| 174 |
global $base_path;
|
| 175 |
$xml .= '<file thumbnail="' . $base_path . $frow->images['thumbnail'] . '" selected="" cparent="' . $parent_level . '" vid="' . $frow->vid . '" weight="' . '0' . '" id="' . $frow->nid . '" icon="file_icon" type="file" name="' . $frow->title . '" description="' . $frow->body . '" path="' . $base_path . $frow->images['_original'] . '" />';
|
| 176 |
|
| 177 |
return $xml;
|
| 178 |
}
|
| 179 |
|
| 180 |
function flex_image_get_folder_parents($array) {
|
| 181 |
if (count($array) > 0) {
|
| 182 |
foreach ($array as $pvalue) {
|
| 183 |
//print $pvalue;
|
| 184 |
$parents .= $pvalue->tid . ',';
|
| 185 |
}
|
| 186 |
}
|
| 187 |
|
| 188 |
return $parents;
|
| 189 |
}
|
| 190 |
|
| 191 |
function flex_image_folder_info($row, $parent_level = '') {
|
| 192 |
if ($row->is_parent) {
|
| 193 |
$xml .= '<folder selected="" cparent="' . $parent_level . '" vid="' . $row->vid . '" weight="' . $row->weight . '" is_parent="' . $row->is_parent . '" id="p' . $row->vid . '" icon="folder_icon" type="folder" name="' . $row->name . '" description="' . $row->description . '">';
|
| 194 |
} else {
|
| 195 |
$parents = flex_image_get_folder_parents($row->parents);
|
| 196 |
$xml .= '<folder selected="" cparent="' . $parent_level . '" vid="' . $row->vid . '" weight="' . $row->weight . '" id="' . $row->tid . '" icon="folder_icon" type="folder" name="' . $row->name . '" description="' . $row->description . '">';
|
| 197 |
}
|
| 198 |
if ($row->is_parent) {
|
| 199 |
$xml .= flex_image_get_folders($row->vid, 0, $parent_level);
|
| 200 |
} else {
|
| 201 |
$xml .= flex_image_get_folders($row->vid, $row->tid, $parent_level);
|
| 202 |
}
|
| 203 |
$xml .= '</folder>';
|
| 204 |
|
| 205 |
return $xml;
|
| 206 |
}
|
| 207 |
|
| 208 |
function flex_image_folders_new() {
|
| 209 |
if ($_POST['id'] != '' && $_POST['name'] != '') {
|
| 210 |
$id = $_POST['id'];
|
| 211 |
if (substr($id, 0, 1) == 'p') $id = 0;
|
| 212 |
|
| 213 |
$form = Array();
|
| 214 |
$form['name'] = $_POST['name'];
|
| 215 |
$form['description'] = $_POST['description'];
|
| 216 |
$form['parent'] = $id;
|
| 217 |
$form['vid'] = $_POST['vid'];
|
| 218 |
|
| 219 |
taxonomy_save_term($form);
|
| 220 |
drupal_get_messages();
|
| 221 |
|
| 222 |
$qr = db_query('select * from {term_data} order by tid desc limit 1');
|
| 223 |
if (mysql_num_rows($qr) > 0) {
|
| 224 |
$row = db_fetch_object($qr);
|
| 225 |
$parent_ar->tid = $id;
|
| 226 |
$row->parents[] = $parent_ar;
|
| 227 |
print flex_image_folder_info($row);
|
| 228 |
}
|
| 229 |
}
|
| 230 |
|
| 231 |
drupal_get_messages();
|
| 232 |
|
| 233 |
exit;
|
| 234 |
}
|
| 235 |
|
| 236 |
function flex_image_on_root($tid) {
|
| 237 |
$qr = db_query('select * from {term_hierarchy} where tid=%d && parent=0', $tid);
|
| 238 |
if (mysql_num_rows($qr) > 0) {
|
| 239 |
return TRUE;
|
| 240 |
}
|
| 241 |
|
| 242 |
return FALSE;
|
| 243 |
}
|
| 244 |
|
| 245 |
function flex_image_folders_edit() {
|
| 246 |
if ($_POST['type'] == 'folder') {
|
| 247 |
$form['name'] = $_POST['name'];
|
| 248 |
$form['description'] = $_POST['desc'];
|
| 249 |
$form['tid'] = $_POST['id'];
|
| 250 |
$form['vid'] = $_POST['vid'];
|
| 251 |
$form['weight'] = $_POST['weight'];
|
| 252 |
|
| 253 |
$ar = taxonomy_get_parents($_POST['id']);
|
| 254 |
$par = Array();
|
| 255 |
if (count($ar) > 0) {
|
| 256 |
foreach ($ar as $key => $value) {
|
| 257 |
$par[] = $key;
|
| 258 |
}
|
| 259 |
}
|
| 260 |
|
| 261 |
if (flex_image_on_root($_POST['id']) > 0) {
|
| 262 |
$par[] = 0;
|
| 263 |
}
|
| 264 |
|
| 265 |
$form['parent'] = $par;
|
| 266 |
taxonomy_save_term($form);
|
| 267 |
print '1';
|
| 268 |
|
| 269 |
drupal_get_messages();
|
| 270 |
exit;
|
| 271 |
}
|
| 272 |
|
| 273 |
if ($_POST['type'] == 'file') {
|
| 274 |
global $user;
|
| 275 |
$node->title = $_POST['name'];
|
| 276 |
$node->body = $_POST['desc'];
|
| 277 |
$node->teaser = $_POST['desc'];
|
| 278 |
$node->nid = $_POST['id'];
|
| 279 |
$node->vid = $_POST['vid'];
|
| 280 |
node_save($node);
|
| 281 |
_node_save_revision($node, $user->uid, TRUE);
|
| 282 |
print '1';
|
| 283 |
drupal_get_messages();
|
| 284 |
exit;
|
| 285 |
}
|
| 286 |
|
| 287 |
drupal_get_messages();
|
| 288 |
print 'Some errors occured while updating.';
|
| 289 |
exit;
|
| 290 |
}
|
| 291 |
|
| 292 |
function flex_image_folders_delete() {
|
| 293 |
if ($_POST['ids'] != '') {
|
| 294 |
$id_ar = explode(',', $_POST['ids']);
|
| 295 |
|
| 296 |
for ($i=0; $i<=count($id_ar)-1; $i++) {
|
| 297 |
if ($id_ar[$i] != '') {
|
| 298 |
$success = FALSE;
|
| 299 |
|
| 300 |
$type = $_POST['type' . $i];
|
| 301 |
|
| 302 |
if ($type == 'folder') {
|
| 303 |
if ($_POST['link_only'] == 0) {
|
| 304 |
//taxonomy_del_term($id_ar[$i]);
|
| 305 |
db_query('delete from {term_data} where tid=%d', $id_ar[$i]);
|
| 306 |
} else {
|
| 307 |
flex_image_remove_from_term($id_ar[$i], $_POST['parent_id']);
|
| 308 |
}
|
| 309 |
$success = TRUE;
|
| 310 |
}
|
| 311 |
|
| 312 |
if ($type == 'file') {
|
| 313 |
if ($_POST['link_only'] == 0) {
|
| 314 |
node_delete($id_ar[$i]);
|
| 315 |
} else {
|
| 316 |
flex_image_remove_from_node($id_ar[$i], $_POST['parent_id']);
|
| 317 |
}
|
| 318 |
$success = TRUE;
|
| 319 |
}
|
| 320 |
}
|
| 321 |
}
|
| 322 |
|
| 323 |
if ($success == TRUE) {
|
| 324 |
print '1';
|
| 325 |
drupal_get_messages();
|
| 326 |
exit;
|
| 327 |
}
|
| 328 |
|
| 329 |
print 'Some errors occured while deleting.';
|
| 330 |
}
|
| 331 |
|
| 332 |
drupal_get_messages();
|
| 333 |
exit;
|
| 334 |
}
|
| 335 |
|
| 336 |
function flex_image_settings() {
|
| 337 |
global $base_url;
|
| 338 |
|
| 339 |
if (user_access('administer flex image gallery')) {
|
| 340 |
print '
|
| 341 |
<settings>
|
| 342 |
<setting name="index_path" value="' . 'index.php' . '" />
|
| 343 |
<setting name="session_id" value="' . variable_get('flex_image_key', '5aeb4487f6b7bd7d1852da8579d0aa6e') . '" />
|
| 344 |
<setting name="access_denied" value="no" />
|
| 345 |
<setting name="clean_url" value="' . variable_get('clean_url', '0') . '" />
|
| 346 |
</settings>
|
| 347 |
';
|
| 348 |
} else {
|
| 349 |
print '
|
| 350 |
<settings>
|
| 351 |
<setting name="access_denied" value="yes" />
|
| 352 |
</settings>
|
| 353 |
';
|
| 354 |
}
|
| 355 |
|
| 356 |
drupal_get_messages();
|
| 357 |
|
| 358 |
exit;
|
| 359 |
}
|
| 360 |
|
| 361 |
function flex_image_new_image() {
|
| 362 |
global $user;
|
| 363 |
|
| 364 |
if ($_POST['image'] != '' && $_POST['id'] != '') {
|
| 365 |
$node->title = $_POST['image'];
|
| 366 |
$node->body = $_POST['desc'];
|
| 367 |
$node->uid = $user->uid;
|
| 368 |
$node->created = mktime();
|
| 369 |
$node->type = 'image';
|
| 370 |
$node->status = 1;
|
| 371 |
$node->images = array('_original' => $_POST['path'], 'thumbnail' => $_POST['path']);
|
| 372 |
$tobj->tid = $_POST['id'];
|
| 373 |
$tobj->vid = $_POST['vid'];
|
| 374 |
$node->taxonomy = array($_POST['id'] => $tobj);
|
| 375 |
node_save($node);
|
| 376 |
//image_insert($node);
|
| 377 |
|
| 378 |
$qr = db_query('select * from {node} order by nid desc limit 1');
|
| 379 |
print flex_image_image_info(db_fetch_object($qr));
|
| 380 |
|
| 381 |
drupal_get_messages();
|
| 382 |
}
|
| 383 |
|
| 384 |
exit;
|
| 385 |
}
|
| 386 |
|
| 387 |
function flex_image_file_exists($id, $image) {
|
| 388 |
$qr = db_query('select * from {flex_image_images} where pfid=%d && file="%s"', $id, $image);
|
| 389 |
if (mysql_num_rows($qr) > 0) return TRUE;
|
| 390 |
|
| 391 |
return FALSE;
|
| 392 |
}
|
| 393 |
|
| 394 |
function flex_image_folders_sizes() {
|
| 395 |
print '<sizes>';
|
| 396 |
|
| 397 |
$sizes = image_get_sizes();
|
| 398 |
foreach ($sizes as $size => $value) {
|
| 399 |
print '<size type="' . $size . '" operation="' . $value['operation'] . '" width="' . $value['width'] . '" height="' . $value['height'] . '" />';
|
| 400 |
}
|
| 401 |
|
| 402 |
print '</sizes>';
|
| 403 |
|
| 404 |
drupal_get_messages();
|
| 405 |
exit;
|
| 406 |
}
|
| 407 |
|
| 408 |
function flex_image_folders_sizes_save() {
|
| 409 |
$items = variable_get('image_sizes', image_get_sizes());
|
| 410 |
|
| 411 |
foreach ($items as $item => $value) {
|
| 412 |
$items[$item]['width'] = $_POST[$item . '_width'];
|
| 413 |
$items[$item]['height'] = $_POST[$item . '_height'];
|
| 414 |
$items[$item]['operation'] = $_POST[$item . '_operation'];
|
| 415 |
}
|
| 416 |
|
| 417 |
variable_set('image_sizes', $items);
|
| 418 |
|
| 419 |
drupal_get_messages();
|
| 420 |
|
| 421 |
print '1';
|
| 422 |
|
| 423 |
exit;
|
| 424 |
}
|
| 425 |
|
| 426 |
function flex_image_download_photo() {
|
| 427 |
if ($_POST['path'] != '') {
|
| 428 |
$_POST['image'] = urldecode($_POST['image']);
|
| 429 |
$contents = file_get_contents($_POST['path']); //load($_POST['path']);
|
| 430 |
|
| 431 |
$filename = 'sites/default/files/' . variable_get('image_default_path', 'images') . '/' . $_POST['image'];
|
| 432 |
|
| 433 |
if (file_exists($filename) == TRUE) {
|
| 434 |
for ($i=1; $i<=2000; $i++) {
|
| 435 |
$file_ar = explode('.', $filename);
|
| 436 |
if (file_exists($file_ar[0] . '(' . $i . ').' . $file_ar[1]) == FALSE) {
|
| 437 |
$filename = $file_ar[0] . '(' . $i . ').' . $file_ar[1];
|
| 438 |
break;
|
| 439 |
}
|
| 440 |
}
|
| 441 |
}
|
| 442 |
|
| 443 |
flex_image_check_path();
|
| 444 |
|
| 445 |
if ($contents == '') {
|
| 446 |
print 'error';
|
| 447 |
} else {
|
| 448 |
$f = fopen($filename, 'w');
|
| 449 |
fwrite($f, $contents);
|
| 450 |
fclose($f);
|
| 451 |
|
| 452 |
$_POST['path'] = $filename;
|
| 453 |
flex_image_new_image();
|
| 454 |
}
|
| 455 |
}
|
| 456 |
|
| 457 |
drupal_get_messages();
|
| 458 |
exit;
|
| 459 |
}
|
| 460 |
|
| 461 |
function flex_image_move_items() {
|
| 462 |
$target = $_POST['target_id'];
|
| 463 |
if (substr($target, 0, 1) == 'p') $target = 0;
|
| 464 |
$move = $_POST['move'];
|
| 465 |
|
| 466 |
for ($i=0; $i<=1000; $i++) {
|
| 467 |
$id = $_POST['item_id' . $i];
|
| 468 |
$type = $_POST['item_type' . $i];
|
| 469 |
$parent = $_POST['item_parent' . $i];
|
| 470 |
if (substr($parent, 0, 1) == 'p') $parent = 0;
|
| 471 |
|
| 472 |
if ($id != '') {
|
| 473 |
if ($type == 'folder') {
|
| 474 |
if ($move == 1) flex_image_remove_from_term($id, $parent);
|
| 475 |
flex_image_insert_into_term($id, $target);
|
| 476 |
|
| 477 |
}
|
| 478 |
if ($type == 'file') {
|
| 479 |
if ($move == 1) flex_image_remove_from_node($id, $parent);
|
| 480 |
flex_image_insert_into_node($id, $target);
|
| 481 |
}
|
| 482 |
}
|
| 483 |
}
|
| 484 |
print '1';
|
| 485 |
|
| 486 |
drupal_get_messages();
|
| 487 |
|
| 488 |
exit;
|
| 489 |
}
|
| 490 |
|
| 491 |
function flex_image_insert_into_term($tid, $parentid) {
|
| 492 |
$qr = db_query('select * from {term_hierarchy} where tid=%d AND parent=%d', $tid, $parentid);
|
| 493 |
if (mysql_num_rows($qr) == 0) db_query('insert into {term_hierarchy} (tid, parent) values (%d, %d)', $tid, $parentid);
|
| 494 |
}
|
| 495 |
|
| 496 |
function flex_image_insert_into_node($nid, $tid) {
|
| 497 |
$qr = db_query('select * from {term_node} where tid=%d AND vid=%d AND nid=%d', $tid, $nid, $nid);
|
| 498 |
if (mysql_num_rows($qr) == 0) db_query('insert into {term_node} (tid, vid, nid) values (%d, %d, %d)', $tid, $nid, $nid);
|
| 499 |
}
|
| 500 |
|
| 501 |
function flex_image_remove_from_term($tid, $parentid) {
|
| 502 |
db_query('delete from {term_hierarchy} where tid=%d AND parent=%d', $tid, $parentid);
|
| 503 |
}
|
| 504 |
|
| 505 |
function flex_image_remove_from_node($nid, $tid) {
|
| 506 |
db_query('delete from {term_node} where tid=%d AND nid=%d', $tid, $nid);
|
| 507 |
}
|
| 508 |
|
| 509 |
function flex_image_show() {
|
| 510 |
$output .= t('<a href="@path">Open Flex Image Gallery</a><br/>', array('@path' => url('') . '?q=flex_image/open'));
|
| 511 |
$output .= t('<br/>You must have at least flash player 9 to view the flex display. To download please <a href="@path" target="blank">click here</a>', array('@path' => 'http://www.adobe.com/products/flashplayer/'));
|
| 512 |
$output .= t('<br/><br/><b>Flex Image</b> incorporates a Flash interface to make managing your photo galleries more intuitive: Search your hard drive for pictures, upload or delete with drag and drop functionality. Also incorporated is a built in web image search.<br/>');
|
| 513 |
$output .= '
|
| 514 |
|
| 515 |
';
|
| 516 |
|
| 517 |
return $output;
|
| 518 |
}
|
| 519 |
|
| 520 |
function flex_image_settings_form() {
|
| 521 |
$form = Array();
|
| 522 |
|
| 523 |
$form['fieldset'] = array(
|
| 524 |
'#type' => 'fieldset',
|
| 525 |
'#title' => 'Settings',
|
| 526 |
'#collapsible' => TRUE,
|
| 527 |
'#collapsed' => TRUE,
|
| 528 |
);
|
| 529 |
|
| 530 |
$form['fieldset']['flex_image_key'] = array(
|
| 531 |
'#type' => 'textfield',
|
| 532 |
'#title' => 'Bridge Key',
|
| 533 |
'#description' => 'A Key that will allow communication between drupal and flex.',
|
| 534 |
'#default_value' => variable_get('flex_image_key', '5aeb4487f6b7bd7d1852da8579d0aa6e'),
|
| 535 |
);
|
| 536 |
|
| 537 |
$form['fieldset']['flex_height'] = array(
|
| 538 |
'#type' => 'textfield',
|
| 539 |
'#title' => 'Height of Flex Display',
|
| 540 |
'#default_value' => variable_get('flex_height', '400px'),
|
| 541 |
'#description' => 'Can be a value in pixels like 400px or in percentage like 80%',
|
| 542 |
);
|
| 543 |
|
| 544 |
$form['fieldset']['flex_width'] = array(
|
| 545 |
'#type' => 'textfield',
|
| 546 |
'#title' => 'Width of Flex Display',
|
| 547 |
'#default_value' => variable_get('flex_width', '100%'),
|
| 548 |
'#description' => 'Can be a value in pixels like 400px or in percentage like 80%',
|
| 549 |
);
|
| 550 |
|
| 551 |
return system_settings_form($form);
|
| 552 |
}
|
| 553 |
|
| 554 |
function flex_image_base_path($mpath = '', $include_base = TRUE) {
|
| 555 |
if ($include_base == TRUE) {
|
| 556 |
$path = base_path() . drupal_get_path('module', 'flex_image');
|
| 557 |
} else {
|
| 558 |
$path = '../' . drupal_get_path('module', 'flex_image');
|
| 559 |
}
|
| 560 |
$ar = explode('/', $path);
|
| 561 |
$new_path = '';
|
| 562 |
for ($i=0; $i<=count($ar)-2; $i++) {
|
| 563 |
if ($i == count($ar) - 2) {
|
| 564 |
if (substr($mpath, 0, 1) == '/') {
|
| 565 |
$new_path .= '..';
|
| 566 |
} else {
|
| 567 |
$new_path .= '../';
|
| 568 |
}
|
| 569 |
} else {
|
| 570 |
$new_path .= '../';
|
| 571 |
}
|
| 572 |
}
|
| 573 |
if ($mpath == '/') $mpath = '';
|
| 574 |
$new_path .= $mpath;
|
| 575 |
|
| 576 |
return $new_path;
|
| 577 |
}
|
| 578 |
|
| 579 |
function flex_image_open() {
|
| 580 |
drupal_add_css(drupal_get_path('module', 'flex_image') . '/flex_image.css');
|
| 581 |
$flex_path = 'flex_image/';
|
| 582 |
$index_path = 'index.php';
|
| 583 |
|
| 584 |
$output .= '<div style="width:' . variable_get('flex_width', '100%') . '; height:' . variable_get('flex_height', '400px') . ';">
|
| 585 |
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
| 586 |
id="flex_image" width="100%" height="100%"
|
| 587 |
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
|
| 588 |
<param name="movie" value="' . drupal_get_path('module', 'flex_image') . '/flex_image.swf" />
|
| 589 |
<param name="quality" value="high" />
|
| 590 |
<param name="bgcolor" value="#869ca7" />
|
| 591 |
<param name="allowScriptAccess" value="always" />
|
| 592 |
<param name="FlashVars" value="flex_path=' . $flex_path . '&index_path=' . $index_path . '" />
|
| 593 |
<embed src="' . drupal_get_path('module', 'flex_image') . '/flex_image.swf" FlashVars="flex_path=' . $flex_path . '&index_path=' . $index_path . '" quality="high" bgcolor="#869ca7"
|
| 594 |
width="100%" height="100%" name="flex_image" align="middle"
|
| 595 |
play="true"
|
| 596 |
loop="false"
|
| 597 |
quality="high"
|
| 598 |
allowScriptAccess="always"
|
| 599 |
type="application/x-shockwave-flash"
|
| 600 |
pluginspage="http://www.adobe.com/go/getflashplayer">
|
| 601 |
</embed>
|
| 602 |
</object>
|
| 603 |
</div>
|
| 604 |
';
|
| 605 |
|
| 606 |
return $output;
|
| 607 |
exit;
|
| 608 |
}
|
| 609 |
|
| 610 |
function flex_image_check_path() {
|
| 611 |
$path = 'sites/default/files/' . variable_get('image_default_path', 'images');
|
| 612 |
$ar = explode('/', $path);
|
| 613 |
|
| 614 |
$vpath = '';
|
| 615 |
for ($i=0; $i<=count($ar)-1; $i++) {
|
| 616 |
$vpath .= $ar[$i] . '/';
|
| 617 |
$mpath = $vpath;
|
| 618 |
file_check_directory($mpath, FILE_CREATE_DIRECTORY);
|
| 619 |
}
|
| 620 |
|
| 621 |
drupal_get_messages();
|
| 622 |
}
|
| 623 |
|
| 624 |
function flex_image_upload() {
|
| 625 |
if ($_REQUEST['session_id'] != variable_get('flex_image_key', '5aeb4487f6b7bd7d1852da8579d0aa6e')) exit;
|
| 626 |
|
| 627 |
$target_path = 'sites/default/files/' . variable_get('image_default_path', 'images') . '/';
|
| 628 |
$filename = $_FILES['Filedata']['name'];
|
| 629 |
$source_path = $_FILES['Filedata']['tmp_name'];
|
| 630 |
|
| 631 |
print '<upload>';
|
| 632 |
|
| 633 |
if ($source_path == '' || $target_path == '') {
|
| 634 |
print '<error type="error" value="File could not be uploaded." /></upload>';
|
| 635 |
drupal_get_messages();
|
| 636 |
exit;
|
| 637 |
}
|
| 638 |
|
| 639 |
if (file_exists($target_path . $filename) == TRUE) {
|
| 640 |
for ($i=1; $i<=2000; $i++) {
|
| 641 |
$file_ar = explode('.', $filename);
|
| 642 |
if (file_exists($target_path . $file_ar[0] . '(' . $i . ').' . $file_ar[1]) == FALSE) {
|
| 643 |
$filename = $file_ar[0] . '(' . $i . ').' . $file_ar[1];
|
| 644 |
break;
|
| 645 |
}
|
| 646 |
}
|
| 647 |
}
|
| 648 |
|
| 649 |
flex_image_check_path();
|
| 650 |
if(file_move($source_path, $target_path . $filename)) {
|
| 651 |
print '<file type="file" id="' . $_REQUEST['id'] . '" name="' . $target_path . $filename . '" />';
|
| 652 |
} else{
|
| 653 |
print '<error type="error" value="There was an error uploading the file, please try again!" />';
|
| 654 |
}
|
| 655 |
|
| 656 |
print '</upload>';
|
| 657 |
|
| 658 |
drupal_get_messages();
|
| 659 |
|
| 660 |
exit;
|
| 661 |
}
|
| 662 |
|
| 663 |
function flex_image_searchgoogle() {
|
| 664 |
include($_POST['url'] . '?hl=' . $_POST['start'] . '&gbv=' . $_POST['gbv'] . '&q=' . urlencode($_POST['q']) . '&start=' . $_POST['start']);
|
| 665 |
|
| 666 |
drupal_get_messages();
|
| 667 |
|
| 668 |
exit;
|
| 669 |
}
|
| 670 |
|
| 671 |
function flex_image_image() {
|
| 672 |
$contents = file_get_contents($_POST['url']);
|
| 673 |
$ar = explode('<body', $contents);
|
| 674 |
if (count($ar) == 1) print $contents;
|
| 675 |
|
| 676 |
drupal_get_messages();
|
| 677 |
|
| 678 |
exit;
|
| 679 |
}
|
| 680 |
|
| 681 |
function flex_image_settings_show() {
|
| 682 |
$output .= drupal_get_form('flex_image_settings_form');
|
| 683 |
|
| 684 |
return $output;
|
| 685 |
}
|
| 686 |
|
| 687 |
function flex_image_unlinked() {
|
| 688 |
$qr = db_query('SELECT n.nid FROM {node} n LEFT JOIN {term_node} t ON ( n.nid = t.nid ) WHERE t.nid IS NULL');
|
| 689 |
|
| 690 |
print '<xml>';
|
| 691 |
|
| 692 |
while ($row = db_fetch_object($qr)) {
|
| 693 |
print flex_image_image_info($row, '', 'unlinked');
|
| 694 |
}
|
| 695 |
|
| 696 |
print '</xml>';
|
| 697 |
|
| 698 |
exit;
|
| 699 |
}
|