'. t('From my gallery, select the image') .'
'.l(t('Upload new image'),'photos/quote',array('query'=> array('type' => 'upload'))); if($_GET['type'] == 'upload'){ if(!_photos_num('useralbum',$user->uid)){ $content .= '

'.l(t('Please create a new album'),'node/add/photos',array('query'=>drupal_get_destination())).'

'; }else { $content .= l(t('Back to'),'photos/quote').'
'.drupal_get_form('photos_upload_form'); } }else{ $content .= ''._photos_teee($user->uid); } echo theme('photos_quote_page', $content); exit(); } function _photos_teee($uid) { $x = '
'.drupal_get_form('_photos_opalbum_form',$uid).'
'.t('Please select checkbox to get photos quoted link.').'
'; if(is_numeric($_GET['type'])){ $pid = $_GET['type']; } if(!$pid){ $p = _photos_sql('allimage','WHERE p.uid = '.$uid,50); }else{ $p = _photos_sql('allimage','WHERE p.uid = '.$uid.' AND p.pid = '.$pid,50); } if($p){ foreach ($p as $b) { $t = _photos_get_path($b, 'list'); if($t['nid']){ $title = _photos_node_title($t['nid']); }else{ $title = _photos_node_title($t['pid']); } $x .= '
'.l('','photos/image/'.$b->fid,array('html' => true)).'
'.t('Thumbnails'). '
' .t('Appropriate'). '
'; }; $x .= theme('pager', NULL, 50); } return $x; } function _photos_opalbum_form(&$form_state,$uid) { $form['albumselect'] = array( '#type' => 'select', '#options' => _photos_useralbum($uid), '#default_value' => $_GET['type'], ); $form['albumsubmit'] = array( '#type' => 'submit', '#value' => t('Select Album'), '#submit' => array('_photos_opalbum_form_submit'), ); $form['insert'] = array('#type' => 'textarea','#cols' => 250, '#rows' => 6); return $form; } function _photos_opalbum_form_submit($form, &$form_state) { $u = $form_state['values']['albumselect']; drupal_goto('photos/quote',array('type' => $u)); } function photos_test_page() { drupal_goto('photos/album'); } function photos_image_flash($node){ if($node->album['count'] || $node->photos['count']){ $output = '
'.l(t('« Back to album'),"node/$node->nid").(variable_get('photos_flash', 0) ? l(t('Flash View image'),"node/$node->nid/photos/view/flash"):NULL).(node_access('update',$node) ? l(t('Organize images'),"node/$node->nid/photos"):NULL).'
'; if($node->album['count']){ $bmb = t('A total of %num images',array('%num' => $node->album['count'])); }else{ $bmb = t('A total of %num images',array('%num' => $node->photos['count'])); } switch (arg(4)){ case 'flash': if(variable_get('photos_flash', 0)){ $xml = url("node/$node->nid/photos/view/xml"); $output .= _photos_flash_swf($xml); $title = t('Flash View image: ').$node->title; } break; case 'xml': if(variable_get('photos_flash', 0)){ if($node->type == 'photos'){ $a = _photos_sql('xml', 'p.pid = '.$node->nid); }else{ $a = _photos_sql('xml', 'p.nid = '.$node->nid); } $b['title'] = t('!name\'s album',array('!name' => $node->name)); if($a){ foreach ($a as $f){ $image[] = $f; } if($image){ $b['xml'] = _photos_flash_xml($image); } } echo theme('photos_flash', $b); return; } break; default: drupal_goto("node/$node->nid/photos/view/flash"); break; } drupal_set_title($title); drupal_set_breadcrumb(array(l(t('Home'),NULL),l($node->title,'node/'.$node->nid),$bmb)); }else{ drupal_not_found(); } return $output; } function _photos_flash_swf($xml) { $swf = base_path() . drupal_get_path('module', 'photos').'/flash_gallery/gallery.swf'; if(variable_get('photos_flash_zoom', '500x450')){ $t = split('x',variable_get('photos_flash_zoom', '500x450')); $width = $t['0']; $height = $t['1']; }else{ $width = 500; $height = 450; } $output .= << EOT; return $output; } function _photos_flash_xml($image = array()){ if($image){ foreach ($image as $a){ $x = _photos_get_path($a, 'list'); $it = image_get_info($x['p']); if(variable_get('photos_flash_show', 0)){ $showurl = $x['p']; }else{ $showurl = $x['p2']; } $node = node_load($x['pid']); if($it['extension'] != 'png' || $it['extension'] != 'PNG'){ $c .= ' '; }else { $c .= ' '; } } } $b = ''; $b .= $c; $b .= ''; return $b; } //单张图片编辑表单 function photos_desedit(&$form_state, $edit){ $form['des'] = array('#type' => 'textarea','#default_value' => '','#cols' => 40, '#rows' => 3); $form['del'] = array( '#title' => t('delete'), '#type' => 'checkbox', ); $form['wid'] = array( '#title' => t('weight'), '#type' => 'weight', '#default_value' => $edit['wid'], ); $form['fid'] = array( '#type' => 'value', '#default_value' => $edit['fid'], ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Confirm the change'), '#submit' => array('photos_desedit_submit'), ); $form['editnone'] = array( '#type' => 'button', '#value' => t('Cancel').$edit['pid'], ); return $form; } //单张图片编辑提交处理 function photos_desedit_submit($form, &$form_state) { global $user; if (!empty($form_state['values']['del'])) { _photos_file_del($$form_state['values']['fid']); $t = db_query('DELETE FROM {x_image} WHERE fid = %d',$form_state['values']['fid']); if($t){ $a = t('Delete success'); }else{ $a = t('Failure to delete'); } drupal_set_message($a); drupal_goto('photos/user/image/'.$user->uid); }else{ $t = db_query("UPDATE {x_image} SET des = '%s', wid = %d WHERE fid = %d", $form_state['values']['des'], $form_state['values']['wid'], $form_state['values']['fid']); if($t){ $a = t('Laws success'); }else{ $a = t('Laws failure'); } drupal_set_message($a); } } function photos_image_view(){ global $user; switch(arg(2)){ case is_numeric(arg(2)): if($image = _photos_get_path(arg(2))){ header('Content-type: '.$image['filemime']); $node = node_load($image['pid']); if(_photos_access_pass_validate($node)){ $t = end(explode('/',$image['path'])); switch (arg(3)){ case 't': $u = str_replace($t,'t_'.$t, $image['path']); break; case 'tt': $u = str_replace($t,'tt_'.$t, $image['path']); break; case 'p': $u = $image['path']; break; } } } break; case 'cover': header('Content-type: '.$image['filemime']); if($image = _photos_get_path_cover(arg(3))){ $t = end(explode('/',$image['path'])); switch (arg(4)){ case 't': $u = str_replace($t,'t_'.$t, $image['path']); break; case 'p': $u = $image['path']; break; } } break; } if(!file_exists($u) || !$u){ $u = variable_get('photos_privacy_default', false) ? variable_get('photos_privacy_default', false): _photos_file_create_url(drupal_get_path(module, photos).'/img/privacy.png'); } if ($fd = fopen($u, 'rb')) { while (!feof($fd)) { print fread($fd, 1024); } fclose($fd); } exit(); } function photos_image_vote(){ global $user; if(is_numeric(arg(2))){ $f = _photos_check_image(arg(2)); if($f->fid){ switch (arg(4)){ case 'up': $value = 1; break; case 'down': $value = -1; break; default: return false; } $vote = array('content_type' => 'image', 'content_id' => $f->fid, 'tag' => 'vote', 'value_type' => 'points', 'uid' => $user->uid, 'value' => $value); $t = votingapi_set_votes($vote); $x = $t['image'][$f->fid]['2']['value'].','.$t['image'][$f->fid]['0']['value']; if($_GET['destination']){ return drupal_goto(); }else { echo $x; exit(); } } } } function photos_image_pageone(){ global $user; if(is_numeric(arg(2))){ $fid = arg(2); $t = _photos_get_path($fid, 'view'); if($t){ $node = node_load($t['pid']); switch (arg(1)){ case 'image': if(!variable_get('photos_image_count', 0)){ db_query('UPDATE {x_image} SET count = count + 1 WHERE fid = %d', $fid); } $title = t('Browse images: ').$node->title; $bmbtitle = t('A total of %num albums under the image',array('%num' => $node->album['count'])); $breadcrumb = array(l(t('Home'), NULL),l($node->title,'node/'.$node->nid), $bmbtitle); $edit = array('fid' => $fid, 'wid' => $t['wid'], 'uid' => $t['uid']); $image = new stdClass(); $image->title = $title; $image->description = !empty($t['des']) ? '
'.$t['des'].'
':NULL; if(_photos_access('edit',$t['uid'])){ $image->editform = '
'.drupal_get_form('photos_desedit',$edit).'
'; } if(_photos_access('edit',$t['uid'])){ $image->links['edit'] = '' .t('Click to change description'). ''; } if(variable_get('photos_vote', 0)){ $sum = votingapi_recalculate_results('image', $fid); if($sum['0']['value']){ $count = $sum['2']['value']; $ren = $sum['0']['value']; }else{ $count = 0; $ren = 0; } $x = votingapi_select_votes(array('uid' => $user->uid, 'content_type' => 'image', 'content_id' => $fid)); if(!user_access('allowed to vote')){ $image->links['vote']['up'] = l('',"user/login",array('query' => drupal_get_destination(), 'attributes' => array('class' => 'photos-vote-u photos-vote-up-u', 'title' => t('Login to vote')), 'html' => true)); $image->links['vote']['down'] = l('',"user/login",array('query' => drupal_get_destination(), 'attributes' => array('class' => 'photos-vote-u photos-vote-down-u', 'title' => t('Login to vote')), 'html' => true)); }else{ $image->links['vote']['up'] = l('',"photos/image/$fid/vote/up",array('query' => drupal_get_destination(), 'attributes' => array('class' => 'photos-vote photos-vote-up', 'title' => t('I like this image')), 'html' => true)); $image->links['vote']['down'] = l('',"photos/image/$fid/vote/down",array('query' => drupal_get_destination(), 'attributes' => array('class' => 'photos-vote photos-vote-down', 'title' => t('I do not like this image')), 'html' => true)); if($x['0']['value'] == 1) { $image->links['vote']['up'] = ''; }elseif($x['0']['value'] == -1){ $image->links['vote']['down'] = ''; } } if(!user_access('view vote list')){ $image->links['vote']['count'] = ''.$count.'/'.$ren.''; }else{ $image->links['vote']['count'] = l(''.$count.'/'.$ren.'',"photos/zoom/$fid/vote",array('html' => true)); } } if(variable_get('photos_comment', 0)){ $commnetcon = photos_vote_comment($fid,1); if(!$commnetcon){ if (!user_access('post comments')) { $image->links['comment'] = t('Login to post comments', array('@login' => url('user/login', array('query' => drupal_get_destination())))); }else{ $image->links['comment'] .= '' .t('Add new comment'). ''; } }elseif($commnetcon > 1){ $image->links['comment'] .= '' .t('!con comments',array('!con' => $commnetcon)). ''; }elseif($commnetcon == 1){ $image->links['comment'] .= '' .t('!con comment',array('!con' => $commnetcon)). ''; } } $options = array(); if (variable_get('photos_open_orig', 0)) { $options['attributes']['target'] = '_blank'; } $image->links['more'] = l(t('View original image'), 'photos/zoom/'.$fid, $options); $image->links['pager'] = _photos_image_pager($fid, $node->nid); $image->view = ''.$t['title'].''; $image->comment['view'] = photos_vote_comment($fid); if (variable_get('photos_comment', 0) && user_access('post comments')) { $image->comment['box'] = comment_form_box(array('nid' => $node->nid), t('Post new comment')); } $output = theme('photos_imageview',$image,$t); drupal_set_title($title); drupal_set_breadcrumb($breadcrumb); break; case 'zoom': if($t['pid']) { $toalbum = l(t('Back to album'),'node/'.$t['pid']); } $output = '
'.l(t('Original Size'),'photos/zoom/'.arg(2)).l(t('Moderate size'),'photos/zoom/'.arg(2).'/2').l(t('Thumbnails'),'photos/zoom/'.arg(2).'/1').(variable_get('photos_vote', 0) && user_access('view vote list') ? l(t('Vote list'),'photos/zoom/'.arg(2).'/vote'):NULL).(variable_get('photos_exif', 0) ? l(t('Show EXIF'),'photos/zoom/'.arg(2).'/exif'):NULL) .$toalbum. l(t('Back to image'),'photos/image/'.arg(2)).'
'; $photolink = '
' .t('Photo html: '). '\' size="100" class="image-quote-link">

' .t('Photo link: '). '

'; switch (arg(3)) { case '1': $output .= $photolink.''; break; case '2': $output .= $photolink.''; break; case 'vote': if(!user_access('view vote list')){ drupal_not_found(); } $header = array( array('data' => t('Vote user'),'align'=> 'center'), array('data' => t('Vote result'),'align'=> 'center'), array('data' => t('Vote time'),'align'=> 'center'), ); $rows = array(); $result = pager_query('SELECT v.uid, u.name, v.value, v.timestamp, v.vote_source FROM {votingapi_vote} v LEFT JOIN {users} u ON u.uid = v.uid WHERE content_type = \'image\' AND content_id = '. $fid . tablesort_sql($header), 30, 0); while ($a = db_fetch_object($result)){ if($a->uid != 0){ $name = theme('username', $a); }else{ $name = $a->vote_source; } $rows[] = array( $name, $a->value, format_date($a->timestamp,'small') ); } if (empty($rows)) { $rows[] = array(array('data' => t('No vote available.'), 'colspan' => 3)); } $output .= theme('table', $header, $rows); $output .= theme('pager', NULL, 30, 0); drupal_set_title(t('See a image vote')); break; case 'exif': $output .= _photos_getexif(_photos_file_create_url($t['p'])); drupal_set_title(t('See a image exif')); break; default: $output .= $photolink.''; if (variable_get('photos_open_orig', 0)) { echo theme('photos_quote_page', $output); exit(); } break; } break; } } } if($output){ return $output; }else{ return drupal_not_found(); } } function _photos_image_tools() { $p = _photos_get_path(arg(3)); if($p){ header("Content-type: image/jpeg"); if(arg(4)=='t'){ $im = @imagecreatefrompng($p['p2']); }elseif(arg(4)=='tt'){ $im = @imagecreatefrompng($p['p1']); }else{ $im = @imagecreatefrompng($p['p']); } echo imagejpeg($im, '', 100); exit(); }else{ drupal_not_found(); } } function photos_image_page(){ $a = _photos_num('image'); if($a){ $output = '
'.t('A total of !img image, !num albums',array('!num' => _photos_num('album'),'!img' => $a)) . l(t('View albums'),'photos/album').'
'; $result = pager_query('SELECT f.filepath, p.* FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid ORDER BY p.wid ASC, p.fid DESC', 50, 0); $output .= '
'; while ($image = db_fetch_object($result)){ $output .= photos_view_list_image($image, 'access'); } $output .= '
'.theme('pager', NULL, 50); }else{ $output .= t('No image'); } return $output; } function photos_album_page() { $a = _photos_num('album'); if($a){ $output = '
'.t('A total of !num albums, !img image',array('!num' => $a, '!img' => _photos_num('image'))) . l(t('View images'),'photos/image').'
'; $b = _photos_sql('album','',10); foreach ($b as $c){ $output .= photos_album_view(node_load($c->pid)); }; $output .= theme('pager', NULL, 10); }else{ $output .= t('No album'); } return $output; } function photos_user_album_page() { global $user; if(is_numeric(arg(3))){ $a = user_load(arg(3)); if($a){ $menu = '
'.t('A total of !num albums, !img image',array('!num' => $a->photos['album'],'!img' => $a->photos['image'])). l(t('View albums'),'photos/user/album/'.$a->uid) . l(t('View images'),'photos/user/image/'.$a->uid) . (variable_get('photos_flash', 0) ? l(t('Flash View image'), 'photos/user/flash/'.$a->uid): NULL).'
'; $output = ''; switch (arg(2)) { case 'image': $bread = l(t('Image'), 'photos/image'); if($user->uid == arg(3)){ $title = t('My image'); }else{ $title = t('!name\'s image',array('!name' => $a->name)); } $aa = _photos_sql('allimage', 'WHERE p.uid = '.$a->uid, 50); if($aa){ $output = $menu; $output .= '
'; foreach ($aa as $b) { $output .= photos_view_list_image($b,'access'); }; $output .= '
'.theme('pager', NULL, 50); }else{ $output = t('No image'); } break; case 'album': $bread = l(t('Album'), 'photos/album'); if($user->uid == arg(3)){ $title = t('My Album'); }else{ $title = t('!name\'s Album',array('!name' => $a->name)); } $b = _photos_sql('album','WHERE uid = '.$a->uid,10); if($b){ $output = $menu; foreach ($b as $c){ $node = node_load($c->pid); $output .= photos_album_view($node); }; $output .= theme('pager', NULL, 10); }else{ $output = t('No album'); } break; case 'flash': if(variable_get('photos_flash', 0)){ if(arg(4)=='xml'){ $result = db_query('SELECT pid FROM {x_album} WHERE uid = %d ORDER BY pid DESC',$a->uid); $i = 0; while ($n = db_fetch_object($result)){ $aaa = _photos_sql('xml', 'p.pid = '.$n->pid); if($aaa){ foreach ($aaa as $f){ $image[$i][] = $f; } if($image[$i]){ $xml .= _photos_flash_xml($image[$i]); } $i++; } } $b['xml'] = $xml; $b['title'] = t('!name\'s album',array('!name' => $a->name)); echo theme('photos_flash', $b); return; }else{ $bread = l(t('Album'),'photos/album'); if($user->uid == arg(3)){ $title = t('My flash'); }else{ $title = t('!name\'s flash',array('!name' => $a->name)); } $xml = url("photos/user/flash/$a->uid/xml"); $output .= $menu . _photos_flash_swf($xml); } } break; } drupal_set_title($title); drupal_set_breadcrumb(array(l(t('Home'),NULL),$bread,drupal_get_title())); } }else{ drupal_not_found(); } return $output; } function photos_album_upload() { global $user; if(!_photos_num('useralbum',$user->uid)){ return '

'.l(t('Please create a new album'),'node/add/photos',array('query'=>drupal_get_destination())).'

'; } $t = drupal_get_form('photos_upload_form'); return $t; } function photos_album_view($node) { global $user; if(node_access('view',$node)){ $node->titlelink = l(check_plain($node->title),'node/'.$node->nid); $node->time = format_date($node->created, 'small'); if(_photos_access('edit',$node->uid)){ $node->albumlink .= l(t('Organize images'),'node/'.$node->nid.'/photos').l(t('Edit album'),'node/'.$node->nid.'/edit',array('query'=>drupal_get_destination())); } $node->albumlink .= l(t('View album'),'node/'.$node->nid); if(variable_get('photos_flash', 0) && $node->album['count']){ $node->albumlink .= l(t('Flash View album'),"node/$node->nid/photos/view/flash"); } return theme('photos_albumview',$node); } } //图片管理 function photos_node_edit($node){ if(arg(3) == 'setcover'){ $setfid = arg(4); $u = _photos_get_path($setfid); if($u['uid'] == $node->uid && node_access('update',$node)){ $fid = $node->album['fid']; if($fid){ $del = db_result(db_query('SELECT fid FROM {x_image} WHERE fid = %d', $fid)); if(!$del){ _photos_file_del($fid,'album'); } } db_query("UPDATE {x_album} SET fid = %d WHERE pid = %d",$setfid, $node->nid); drupal_set_message(t('Cover successfully set.')); return drupal_goto(); }else{ return drupal_not_found(); } } $output = '
'.l(t('« Back to'),"node/$node->nid").(variable_get('photos_flash', 0) ? l(t('Flash View image'),"node/$node->nid/photos/view/flash"):NULL).(node_access('update',$node) ? l(t('Organize images'),"node/$node->nid/photos"):NULL).'
'; if (variable_get('photos_'.$node->type, false)){ $output .= t('You are in management article !title image. A total of !num images. ',array('!title' => $node->title, '!num' => $node->photos['count'])); }elseif($node->album['pid']){ $output .= t('You are in management album !title image. A total of !num images. ',array('!title' => $node->title, '!num' => $node->album['count'])); }else{ drupal_not_found(); return; } drupal_set_title(t('Organize images: ').$node->title); drupal_set_breadcrumb(array(l(t('Home'), NULL),l($node->title,'node/'.$node->nid),drupal_get_title())); $output .= '
'.drupal_get_form('photos_upload_form',$node).'
'; if($node->album['count'] || $node->photos['count']){ $output .= drupal_get_form('photos_editlist'); } return $output; } //站点图片管理 function photos_admin_edit(){ $output = ''; $output .= drupal_get_form('photos_editlist'); return $output; } function photos_admin_import(){ global $user; $info = _photos_upload_info(); $form['new']['unzip'] = array( '#title' => t('Import zip'), '#type' => 'textfield', '#description' => t('From the server directory into zip files, to extract. You can upload images to a directory server, enter here path, you can extract and add to the album phtos. Path such as: !zip/test.zip. Documents must be read and write, php can operate.',array('!zip'=>$info['p'])), '#weight' => -3, ); $form['new']['pid'] = array( '#title' => t('Upload to album'), '#type' => 'select', '#options' => _photos_useralbum($user->uid), '#default_value' => $_GET['pid'], '#required' => TRUE, '#description' => '

'.l(t('You may create a new album'),'node/add/photos',array('query'=>drupal_get_destination())).'

', '#weight' => -5, ); $form['new']['submit'] = array( '#type' => 'submit', '#value' => t('Confirm upload'), '#weight' => -2, '#submit' => array('photos_upload_form_submit'), ); $n->uid = $user->uid; $form['date'] = array('#type' => 'value','#value' => $n); $form['#attributes']['enctype'] = 'multipart/form-data'; return $form; } function photos_editlist(&$form_state) { $form['photos']['#theme'] = 'photos_editlist_x'; $form['photos']['#tree'] = true; $paging = ''; if (isset($_GET['page'])) { $paging = '&page=' . intval($_GET['page']); } $form['#action'] = url($_GET['q'], array('query' => drupal_get_destination(). $paging)); if(arg(1) != 'admin'){ $node = node_load(arg(1)); if($node->type == 'photos'){ $sql = 'WHERE p.pid = '.$node->nid; $albumfid = $node->album['fid']; }else{ $sql = 'WHERE p.nid = '.$node->nid; } } $a = _photos_sql('allimage',$sql, 20); if($a){ foreach ($a as $img) { $fid = $img->fid; if($node->type == 'photos'){ if($img->nid){ $tn = node_load($img->nid); $title = t('Uploaded to the article ').l($tn->title,'node/'.$tn->nid); } }elseif($img->pid){ $tn = node_load($img->pid); $albumfid = $tn->album['fid']; $title = t('Categories in the album ').l($tn->title,'node/'.$tn->nid); } if($fid != $albumfid){ $setcover = l(t('Set to album cover.'),"node/$img->pid/photos/setcover/$fid", array('query' => drupal_get_destination())); }else{ $setcover = false; } $p = _photos_get_path($img, 'list'); $form['photos'][$fid]['del'] = array('#type' => 'checkbox'); $form['photos'][$fid]['path'] = array('#value' => l('','photos/image/'.$fid,array('html'=>true))); $form['photos'][$fid]['des'] = array('#type' => 'textarea','#default_value' => $img->des,'#cols' => 40, '#rows' => 4); $form['photos'][$fid]['time'] = array('#value' => $setcover.t('Upload the images in ').format_date($img->timestamp, 'small').'。'.$title); $form['photos'][$fid]['wid'] = array('#type' => 'weight','#default_value' => $img->wid, '#delta' => 100,); $form['photos'][$fid]['pid'] = array( '#type' => 'select', '#options' => _photos_useralbum($img->uid), '#default_value' => $img->pid, '#required' => TRUE, ); $form['photos'][$fid]['uid'] = array('#type' => 'hidden', '#default_value' => $img->uid,); $form['photos'][$fid]['oldpid'] = array('#type' => 'value', '#value' => $img->pid,); }; } $form['allck'] = array('#value' =>''.t('Select All').' | ' .t('Deselect'). ''); $form['submit'] = array( '#type' => 'submit', '#value' => t('Confirm the change'), '#submit' => array('photos_editlist_submit'), ); return $form; } function photos_editlist_submit($form, &$form_state) { global $user; foreach($form_state['values']['photos'] as $fid => $key) { if (!empty($key['del'])) { _photos_file_del($fid); db_query('DELETE FROM {x_image} WHERE fid = %d', $fid); db_query('DELETE FROM {x_vote} WHERE fid = %d', $fid); db_query('DELETE FROM {comments} WHERE cid IN (SELECT cid FROM {x_vote} WHERE fid = %d)', $fid); _comment_update_node_statistics($key['pid']); }else{ db_query("UPDATE {x_image} SET pid = %d, des = '%s', wid = %d WHERE fid = %d", $key['pid'],$key['des'], $key['wid'], $fid); if ($key['pid'] != $key['oldpid']) { db_query('UPDATE {comments} SET nid = %d WHERE cid IN (SELECT cid FROM {x_vote} WHERE fid = %d)', $key['pid'], $fid); _comment_update_node_statistics($key['pid']); _comment_update_node_statistics($key['oldpid']); } } } } function theme_photos_editlist_x($form) { $node = node_load(arg(1)); if($node->type == 'photos'){ $title = t('Move to the album'); }else{ $title = t('His album'); } $header = array( array('data' => t('Delete'),'align'=> 'center','width' => 60), array('data' => t('Thumbnails'),'align'=> 'center','width' => 120), array('data' => t('Description'),'align'=> 'center'), array('data' => $title,'align'=> 'center'), array('data' => t('Weight'),'align'=> 'center','width' => 60) ); if(!empty($node->photos['count']) || !empty($node->album['count']) || _photos_num('album')){ foreach (element_children($form) as $key) { $row = array(); $row[] = drupal_render($form[$key]['del']); $row[] = drupal_render($form[$key]['path']); $row[] = drupal_render($form[$key]['des']); $row[] = drupal_render($form[$key]['pid']); $row[] = drupal_render($form[$key]['wid']); $rows[] = $row; $rows[] = array(array('data' => drupal_render($form[$key]['time']), 'class'=> 'photos-des','colspan' => '5')); } }else { $rows[] = array(array('data' => t('No image'), 'colspan' => '5')); } $output = theme('table', $header, $rows,array('id'=>'imagesedit')); $output .= theme('pager', NULL, 20, 0); $output .= drupal_render($form['allck']); $output .= drupal_render($form['submit']); return $output; } //comment function photos_vote_comment($fid,$con = false){ global $user; $t = db_result(db_query('SELECT count(fid) FROM {x_vote} WHERE fid = '.$fid)); if(!$t){ return false;} $output = ''; if($con){ $output = $t; }elseif(module_exists('comment')) { if(user_access('access comments')) { $node->type = 'photos'; $mode = _comment_get_display_setting('mode', $node); $order = _comment_get_display_setting('sort', $node); $comments_per_page = _comment_get_display_setting('comments_per_page', $node); //$query_count = $t; $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid INNER JOIN {x_vote} x ON c.cid = x.cid WHERE x.fid = %d'; $query_args = array($fid); if (!user_access('administer comments')) { $query .= ' AND c.status = %d'; //$query_count .= ' AND c.status = %d'; $query_args[] = COMMENT_PUBLISHED; } if ($order == COMMENT_ORDER_NEWEST_FIRST) { if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) { $query .= ' ORDER BY c.cid DESC'; }else { $query .= ' ORDER BY c.thread DESC'; } }else if ($order == COMMENT_ORDER_OLDEST_FIRST) { if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) { $query .= ' ORDER BY c.cid'; }else { $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))'; } } $query = db_rewrite_sql($query, 'c', 'cid'); //$query_count = db_rewrite_sql($query_count, 'c', 'cid'); $result = pager_query($query, $comments_per_page, 0, NULL, $query_args); $divs = 0; $num_rows = FALSE; $comments = ''; drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css'); while ($comment = db_fetch_object($result)) { $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $comment->depth = count(explode('.', $comment->thread)) - 1; if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) { if ($comment->depth > $divs) { $divs++; $comments .= '
'; } else { while ($comment->depth < $divs) { $divs--; $comments .= '
'; } } } if(user_access('administer comments')){ $links['comment_delete'] = array( 'title' => t('delete'), 'href' => "comment/delete/$comment->cid", 'query' => drupal_get_destination() ); $links['comment_edit'] = array( 'title' => t('edit'), 'href' => "comment/edit/$comment->cid", 'query' => drupal_get_destination() ); } if(user_access('post comments')){ $links['comment_reply'] = array( 'title' => t('reply'), 'href' => "comment/reply/$comment->nid/$comment->cid", 'query' => array('fid' => $fid) ); } if ($mode == COMMENT_MODE_FLAT_COLLAPSED) { $comments .= theme('comment_flat_collapsed', $comment, $node); }else if ($mode == COMMENT_MODE_FLAT_EXPANDED) { //$comments .= theme('comment_flat_expanded', $comment, $node); $comments .= theme('comment_view', $comment, $node, $links); }else if ($mode == COMMENT_MODE_THREADED_COLLAPSED) { $comments .= theme('comment_thread_collapsed', $comment, $node); }else if ($mode == COMMENT_MODE_THREADED_EXPANDED) { //$comments .= theme('comment_thread_expanded', $comment, $node); $comments .= theme('comment_view', $comment, $node, $links); } $num_rows = TRUE; } while ($divs-- > 0) { $comments .= ''; } $comment_controls = variable_get('comment_controls_'. $node->type, COMMENT_CONTROLS_HIDDEN); if ($num_rows && ($comment_controls == COMMENT_CONTROLS_ABOVE || $comment_controls == COMMENT_CONTROLS_ABOVE_BELOW)) { $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page); } $output .= $comments; $output .= theme('pager', NULL, $comments_per_page, 0); if ($num_rows && ($comment_controls == COMMENT_CONTROLS_BELOW || $comment_controls == COMMENT_CONTROLS_ABOVE_BELOW)) { $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page); } } $output = theme('comment_wrapper', $output, $node); } return $output; } // function _photos_getval($ImageInfo,$val_arr) { $InfoVal = t('Unknown'); foreach($val_arr as $name=>$val) { if ($name==$ImageInfo) { $InfoVal = &$val; break; } } return $InfoVal; } function _photos_getexif($img, $type = false, $url = false) { $imgtype = array('', 'GIF', 'JPG', 'PNG', 'SWF', 'PSD', 'BMP', 'TIFF(intel byte order)', 'TIFF(motorola byte order)', 'JPC', 'JP2', 'JPX', 'JB2', 'SWC', 'IFF', 'WBMP', 'XBM'); $Orientation = array('', t('top left side'), t('top right side'), t('bottom right side'), t('bottom left side'), t('left side top'), t('right side top'), t('right side bottom'), t('left side bottom')); $ResolutionUnit = array('', '', t('inches'), t('centimeters')); $YCbCrPositioning = array('', t('the center of pixel array'), t('the datum point')); $ExposureProgram = array(t('Not defined'), t('Manual'), t('Normal program'), t('Aperture priority'), t('Shutter priority'), t('Creative program (biased toward depth of field)'), t('Action program (biased toward fast shutter speed)'), t('Portrait mode (for closeup photos with the background out of focus)'), t('Landscape mode (for landscape photos with the background in focus)')); $MeteringMode_arr = array( '0' => t('unknown'), '1' => t('Average'), '2' => t('CenterWeightedAverage'), '3' => t('Spot'), '4' => t('MultiSpot'), '5' => t('Pattern'), '6' => t('Partial'), '255' => t('other') ); $Lightsource_arr = array( '0' => t('unknown'), '1' => t('Daylight'), '2' => t('Fluorescent'), '3' => t('Tungsten (incandescent light)'), '4' => t('Flash'), '9' => t('Fine weather'), '10' => t('Cloudy weather'), '12' => t('Daylight fluorescent (D 5700 – 7100K)'), '13' => t('Day white fluorescent (N 4600 – 5400K)'), '14' => t('Cool white fluorescent (W 3900 – 4500K)'), '15' => t('White fluorescent (WW 3200 – 3700K)'), '17' => t('Standard light A'), '18' => t('Standard light B'), '19' => t('Standard light C'), '20' => 'D55', '21' => 'D65', '22' => 'D75', '23' => 'D50', '24' => t('ISO studio tungsten'), '255' => t('other light source') ); $Flash_arr = array( '0' => t('Flash did not fire.'), '1' => t('Flash fired.'), '5' => t('Strobe return light not detected.'), '7' => t('Strobe return light detected.'), '9' => t('Flash fired, compulsory flash mode'), '13' => t('Flash fired, compulsory flash mode, return light not detected'), '15' => t('Flash fired, compulsory flash mode, return light detected'), '16' => t('Flash did not fire, compulsory flash mode'), '24' => t('Flash did not fire, auto mode'), '25' => t('Flash fired, auto mode'), '29' => t('Flash fired, auto mode, return light not detected'), '31' => t('Flash fired, auto mode, return light detected'), '32' => t('No flash function'), '65' => t('Flash fired, red-eye reduction mode'), '69' => t('Flash fired, red-eye reduction mode, return light not detected'), '71' => t('Flash fired, red-eye reduction mode, return light detected'), '73' => t('Flash fired, compulsory flash mode, red-eye reduction mode'), '77' => t('Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected'), '79' => t('Flash fired, compulsory flash mode, red-eye reduction mode, return light detected'), '89' => t('Flash fired, auto mode, red-eye reduction mode'), '93' => t('Flash fired, auto mode, return light not detected, red-eye reduction mode'), '95' => t('Flash fired, auto mode, return light detected, red-eye reduction mode') ); $exif = @exif_read_data ($img,'IFD0'); if ($exif) { $exif = @exif_read_data($img,0,true); if($type == 't'){ $new_img_info = array ( 'Artist' => $exif[IFD0][Artist], 'FileType' => $imgtype[$exif[FILE][FileType]], 'MimeType' => $exif[FILE][MimeType], 'FileSize' => (floor($exif[FILE][FileSize] / 1024 * 10 )/10).'KB', 'FileDateTime' => date('Y:m:d H:i:s',$exif[FILE][FileDateTime]), 'Make' => $exif[IFD0][Make], 'Model' => $exif[IFD0][Model], 'DateTime' => $exif[IFD0][DateTime], 'ExifVersion' => $exif[EXIF][ExifVersion], 'DateTimeOriginal' => $exif[EXIF][DateTimeOriginal], 'DateTimeDigitized' => $exif[EXIF][DateTimeDigitized], 'Height' => $exif[COMPUTED][Height].'px', 'Width' => $exif[COMPUTED][Width].'px', 'CompressedBitsPerPixel' => $exif[EXIF][CompressedBitsPerPixel].'Bits/Pixel', 'FocusDistance' => !empty($exif[COMPUTED][FocusDistance]) ? $exif[COMPUTED][FocusDistance].'m':NULL, 'FocalLength' => !empty($exif[EXIF][FocalLength]) ? $exif[EXIF][FocalLength].'mm':NULL, 'FocalLengthIn35mmFilm' => !empty($exif[EXIF][FocalLengthIn35mmFilm]) ? $exif[EXIF][FocalLengthIn35mmFilm].'mm':NULL, 'ColorSpace' => ($exif[EXIF][ColorSpace]==1?'sRGB':'Uncalibrated'), ); $more = l(t('Show details'),$url); }else{ $new_img_info = array ( 'FileName' => $exif[FILE][FileName], 'FileType' => $imgtype[$exif[FILE][FileType]], 'MimeType' => $exif[FILE][MimeType], 'FileSize' => (floor($exif[FILE][FileSize] / 1024 * 10 )/10).'KB', 'FileDateTime' => date('Y-m-d H:i:s',$exif[FILE][FileDateTime]), 'ImageDescription' => $exif[IFD0][ImageDescription], 'Make' => $exif[IFD0][Make], 'Model' => $exif[IFD0][Model], 'Orientation' => $Orientation[$exif[IFD0][Orientation]], 'XResolution' => $exif[IFD0][XResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]], 'YResolution' => $exif[IFD0][YResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]], 'Software' => drupal_convert_to_utf8($exif[IFD0][Software],'gbk'), 'DateTime' => $exif[IFD0][DateTime], 'Artist' => $exif[IFD0][Artist], 'YCbCrPositioning' => $YCbCrPositioning[$exif[IFD0][YCbCrPositioning]], 'Copyright' => $exif[IFD0][Copyright], 'Photographer' => $exif[COMPUTED][Copyright.Photographer], 'Editor' => $exif[COMPUTED][Copyright.Editor], 'ExifVersion' => $exif[EXIF][ExifVersion], 'FlashPixVersion' => 'Ver. '.number_format($exif[EXIF][FlashPixVersion]/100,2), 'DateTimeOriginal' => $exif[EXIF][DateTimeOriginal], 'DateTimeDigitized' => $exif[EXIF][DateTimeDigitized], 'Height' => $exif[COMPUTED][Height].'px', 'Width' => $exif[COMPUTED][Width].'px', 'ApertureValue' => $exif[EXIF][ApertureValue], 'ShutterSpeedValue' => $exif[EXIF][ShutterSpeedValue], 'ApertureFNumber' => $exif[COMPUTED][ApertureFNumber], 'MaxApertureValue' => 'F'.$exif[EXIF][MaxApertureValue], 'ExposureTime' => $exif[EXIF][ExposureTime], 'F-Number' => $exif[EXIF][FNumber], 'MeteringMode' => _photos_getval($exif[EXIF][MeteringMode],$MeteringMode_arr), 'LightSource' => _photos_getval($exif[EXIF][LightSource], $Lightsource_arr), 'Flash' => _photos_getval($exif[EXIF][Flash], $Flash_arr), 'ExposureMode' => ($exif[EXIF][ExposureMode]==1?'Manual exposure':'Auto exposure'), 'WhiteBalance' => ($exif[EXIF][WhiteBalance]==1?'Manual white balance':'Auto white balance'), 'ExposureProgram' => $ExposureProgram[$exif[EXIF][ExposureProgram]], 'ExposureBiasValue' => $exif[EXIF][ExposureBiasValue].'EV', 'ISOSpeedRatings' => $exif[EXIF][ISOSpeedRatings], 'ComponentsConfiguration' => (bin2hex($exif[EXIF][ComponentsConfiguration])=='01020300'?'YCbCr':'RGB'), 'CompressedBitsPerPixel' => $exif[EXIF][CompressedBitsPerPixel].'Bits/Pixel', 'FocusDistance' => $exif[COMPUTED][FocusDistance].'m', 'FocalLength' => $exif[EXIF][FocalLength].'mm', 'FocalLengthIn35mmFilm' => $exif[EXIF][FocalLengthIn35mmFilm].'mm', 'UserCommentEncoding' => $exif[COMPUTED][UserCommentEncoding], 'UserComment' => $exif[COMPUTED][UserComment], 'ColorSpace' => ($exif[EXIF][ColorSpace]==1?'sRGB':'Uncalibrated'), 'ExifImageLength' => $exif[EXIF][ExifImageLength], 'ExifImageWidth' => $exif[EXIF][ExifImageWidth], 'FileSource' => (bin2hex($exif[EXIF][FileSource])==0x03?'DSC':'unknown'), 'SceneType' => (bin2hex($exif[EXIF][SceneType])==0x01?'A directly photographed image':'unknown'), 'Thumbnail.FileType' => $exif[COMPUTED][Thumbnail.FileType], 'Thumbnail.MimeType' => $exif[COMPUTED][Thumbnail.MimeType] ); } }elseif($type != 't'){ $new_img_info = array (t('Information') => t('This image does not EXIF information')); } $output = ''; if($new_img_info){ $header = array(array('data'=> t('EXIF information')),array('data'=>$more,'class'=>'rg')); foreach($new_img_info as $name=>$val) { $row = array(); if($val){ $row[] = $name; $row[] = $val; $rows[] = $row; } } $output = theme('table', $header, $rows,array('id'=>'photo-exif')); } return $output; }