Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/include/crop.inc.php,v $
15
  $Revision: 1.5 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:11 $
18
**********************************************/
19
 
20
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
21
//////////////////// Variables //////////////////////////////
22
// used texts
23
$txt['bigger'] = ">";
24
$txt['smaller'] = "<";
25
$txt['up'] = "^";
26
$txt['down'] = "v";
27
$txt['closewindow'] = "Close window";
28
 
29
 
30
$result = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = '$pid'");
31
$CURRENT_PIC = mysql_fetch_array($result);
32
mysql_free_result($result);
33
$pic_url = get_pic_url($CURRENT_PIC,'fullsize');
34
 
35
 
36
 
37
echo <<<cropUIjs
38
<script language="JavaScript" src="dhtmlLib.js"></script>
39
<script language="JavaScript">
40
<!--
41
 
42
function libinit(){
43
        obj=new lib_obj('cropDiv')
44
        obj.dragdrop()
45
        objImg =new lib_obj('imgDiv')
46
        //alert (objImg.x + "-" + objImg.y);
47
        obj.moveIt(objImg.x,objImg.y)
48
}
49
 
50
function cropCheck(crA){
51
  //alert (obj.x + "-" + obj.y);
52
  if (((obj.x + obj.cr) <= ({$CURRENT_PIC['pwidth']}+objImg.x))&&((obj.y + obj.cb) <= ({$CURRENT_PIC['pheight']}+objImg.y))&&(obj.x > objImg.x)&&(obj.y > objImg.y)){
53
    cropX = obj.x - objImg.x;
54
    cropY = obj.y - objImg.y;
55
    var url = 'cropAction.php?pop=1&x='+cropX+'&y='+cropY+'&h='+obj.cb+'&w='+obj.cr+'&id={$pid}' ;
56
    if (crA == 'pre'){
57
      window.open(url,'prevWin','width='+obj.cr+',height='+obj.cb);
58
    }else if(crA == 'final') {
59
      url = url+'&final=1';
60
      window.open(url,'prevWin','width='+obj.cr+',height='+(obj.cb));
61
    }else if(crA == 'asThumb') {
62
 
63
        thumb_use = "{$CONFIG['thumb_use']}"
64
        thumb_width = {$CONFIG['thumb_width']}
65
 
66
        if ( thumb_use== "ht") {
67
                ratio = obj.cb / thumb_width ;
68
        } else if (thumb_use == "wd") {
69
                ratio = obj.cr / thumb_width ;
70
        } else {
71
                ratio = Math.max(obj.cb, obj.cr) / thumb_width ;
72
        }
73
 
74
        ratio = Math.max(ratio, 1.0);
75
        destWidth = (obj.cr / ratio);
76
        destHeight = (obj.cb / ratio);
77
 
78
      url = url+'&asThumb=1';
79
      window.open(url,'prevWin','width='+destWidth+',height='+destHeight);
80
      }
81
    } else {
82
     alert('{$lang_editpics_php['sel_on_img']}');
83
    }
84
  }
85
 
86
 
87
function stopZoom() {
88
  loop = false;
89
  clearTimeout(zoomtimer);
90
}
91
 
92
function cropZoom(dir) {
93
  loop = true;
94
  zoomtimer = null;
95
  direction = dir;
96
  if (loop == true) {
97
    if (direction == "in") {
98
      if ((obj.cr > 60 )){
99
        cW = obj.cr - 1;
100
        cH = obj.cb ;
101
        obj.clipTo(0,cW,cH,0,1);
102
      }
103
    } else if (direction == "out") {
104
      if ((obj.cr < ({$CURRENT_PIC['pwidth']}-5))){
105
        cW = obj.cr + 1;
106
        cH = obj.cb ;
107
        obj.clipTo(0,cW,cH,0,1);
108
      }
109
    } else if (direction == "down") {
110
      if ((obj.cb < ({$CURRENT_PIC['pheight']}-5) )){
111
        cW = obj.cr ;
112
        cH = obj.cb + 1;
113
        obj.clipTo(0,cW,cH,0,1);
114
      }
115
    } else if (direction == "up") {
116
      if ((obj.cb > 60 )){
117
        cW = obj.cr ;
118
        cH = obj.cb - 1;
119
        obj.clipTo(0,cW,cH,0,1);
120
      }
121
    }
122
    zoomtimer = setTimeout("cropZoom(direction)", 10);
123
  }
124
}
125
 
126
onload=libinit;
127
// -->
128
</script>
129
<style>
130
 
131
#cropDiv{
132
        position:absolute;
133
        left:10px;
134
        top:10px;
135
        width:60px;
136
        height:60px;
137
        z-index:2;
138
        background-image: url(images/spacer.gif);
139
}
140
 
141
#imgDiv{
142
        position:relative;
143
}
144
</style>
145
cropUIjs;
146
 
147
starttable("100%",$lang_editpics_php['crop_title'], 3);
148
echo <<<EOT
149
<tr><td>
150
<table cellspacing="0" cellpadding="5" border="0" align="center">
151
<tr><td>
152
<table cellspacing="0" cellpadding="5" border="0" align="center">
153
<tr><td align="center" valign="top"><div ID="imgDiv"><img src="$pic_url"></div></td></tr>
154
</table>
155
<table border="0">
156
<tr>
157
<td align="right">
158
    <input type="button" name="Submit2" value="{$lang_editpics_php['save_thumb']}" onclick="cropCheck('asThumb');" class="button" />
159
    <input type="button" name="Submit2" value="{$lang_editpics_php['save']}" onclick="cropCheck('final');" class="button" />
160
    <input type="button" name="Submit2" value="{$lang_editpics_php['preview']}" onclick="cropCheck('pre');" class="button" />
161
    <input type="button" name="Submit3" value="{$txt['smaller']}" onMouseDown="cropZoom('in');" onMouseUp="stopZoom();" class="button" />
162
    <input type="button" name="Submit3" value="{$txt['up']}" onMouseDown="cropZoom('up');" onMouseUp="stopZoom();" class="button" />
163
    <input type="button" name="Submit3" value="{$txt['down']}" onMouseDown="cropZoom('down');" onMouseUp="stopZoom();" class="button" />
164
    <input type="button" name="Submit4" value="{$txt['bigger']}" onMouseDown="cropZoom('out');" onMouseUp="stopZoom();" class="button" />
165
</td>
166
</tr>
167
  </form>
168
</table>
169
</td></tr>
170
</table>
171
</td></tr>
172
</table>
173
 
174
<div id="cropDiv">
175
  <table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
176
<tr>
177
      <td><img src="images/spacer.gif"></td>
178
    </tr>
179
  </table>
180
</div>
181
EOT;
182
?>