root/afridex/plugins/fresh-page/cropper.php @ 23

Revision 21, 6.5 kB (checked in by admin, 18 years ago)
Line 
1
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4<head>
5        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
7        <title>
8                <?php //bloginfo('name') ?> &rsaquo;
9                <?php //echo wp_specialchars( strip_tags( $title ) ); ?>
10                &#8212; WordPress
11        </title>
12
13        <?php //wp_admin_css(); ?>
14    <link href="../../../wp-admin/wp-admin.css" rel="stylesheet" type="text/css" media="all" />
15
16        <script type="text/javascript" src="./js/greybox.js"></script> 
17        <script type="text/javascript" src="./js/lib/prototype.js"></script>   
18        <script type="text/javascript" src="./js/lib/scriptaculous.js?load=builder,dragdrop"></script>
19        <script type="text/javascript" src="./js/cropper.js"></script>
20        <script type="text/javascript">
21        function MM_swapImgRestore() { //v3.0
22          var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
23        }
24       
25        function MM_preloadImages() { //v3.0
26          var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
27                var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
28                if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
29        }
30       
31        function MM_findObj(n, d) { //v4.01
32          var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
33                d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
34          if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
35          for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
36          if(!x && d.getElementById) x=d.getElementById(n); return x;
37        }
38       
39        function MM_swapImage() { //v3.0
40          var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
41           if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
42        }
43        //-->
44        </script>
45        <script type="text/javascript" charset="utf-8">
46                // setup the callback function
47                function onEndCrop( coords, dimensions ) {
48                        $( 'x1' ).value = coords.x1;
49                        $( 'y1' ).value = coords.y1;
50                        $( 'x2' ).value = coords.x2;
51                        $( 'y2' ).value = coords.y2;
52                        $( 'width' ).value = dimensions.width;
53                        $( 'height' ).value = dimensions.height;
54                }
55               
56                // basic example
57                Event.observe( 
58                        window, 
59                        'load', 
60                        function() { 
61                                new Cropper.Img( 
62                                        'testImage',
63                                        {
64                                                onEndCrop: onEndCrop 
65                                        }
66                                ) 
67                        }
68                );             
69               
70               
71                if( typeof(dump) != 'function' ) {
72                        Debug.init(true, '/');
73                       
74                        function dump( msg ) {
75                                Debug.raise( msg );
76                        };
77                } else dump( '---------------------------------------\n' );
78        </script>
79        <script type="text/javascript" charset="utf-8">
80
81                function imageCrop()
82                {
83                        if(document.getElementById('x1').value != '0')
84                        {
85                                x1 = document.getElementById('x1').value;
86                                y1 = document.getElementById('y1').value;
87                                x2 = document.getElementById('x2').value;
88                                y2 = document.getElementById('y2').value;
89
90                                w = document.getElementById('width').value;
91                                h = document.getElementById('height').value;
92
93                                sourceImage = document.getElementById('sourceImage').value;
94
95                                if(sourceImage.indexOf("&sw=") != "-1")
96                                {
97//                                      cropValue1 = document.getElementById("cropValues2").value;
98//                                      cropValue2 = document.getElementById("cropValues3").value;
99                                        cropValue3 = document.getElementById("cropValues4").value;
100                                        cropValue4 = document.getElementById("cropValues5").value;
101
102                                        x1 = parseInt(cropValue3) + parseInt(x1);
103                                        y1 = parseInt(cropValue4) + parseInt(y1);
104
105                                        sourceImage = sourceImage.substring(0, sourceImage.indexOf("&sw="));
106                                }
107
108                                requiredString = sourceImage+"&sw="+w+"&sh="+h+"&sx="+x1+"&sy="+y1;
109                        }
110                        else
111                                requiredString = document.getElementById('sourceImage').value;
112
113                        document.getElementById('tempSrc').value = requiredString;
114                        parent.exchangeValues(requiredString, document.getElementById('imageThumbId').value); 
115//                      parent.$("img_thumb_1").src = requiredString + "&w=150&h=120";
116                        parent.$(document.getElementById('imageThumbId').value).src = requiredString + "&w=150&h=120";
117
118                        parent.GB_hide();
119                        console.log(requiredString);
120                }
121        </script>
122        <link rel="stylesheet" type="text/css" href="debug.css" media="all" />
123        <style type="text/css">
124                label { 
125                        clear: left;
126                        margin-left: 50px;
127                        float: left;
128                        width: 5em;
129                        }
130               
131                html, body { 
132                        margin: 0;
133                        }
134               
135                #testWrap {
136                        margin:8px; /* Just while testing, to make sure we return the correct positions for the image & not the window */
137                        }
138        </style>
139</head>
140<body onload="MM_preloadImages('./images/ajax-loader.gif')">
141        <div align="center" id="freshpostProgressBar" name="freshpostProgressBar" style="position:absolute; bottom:50%; left:30%; z-index:0; display:inline; background:#fff; border:1px solid #666;">
142                Loading...
143                <div><img src="./images/ajax-loader.gif" /></div>
144        </div>
145        <form name="frmCroper" action="" method="post">
146        <?php 
147                if(isset($_GET['sw'])) {
148                        $finalSrc = $_GET['id']."&sw=".$_GET['sw']."&sh=".$_GET['sh']."&sx=".$_GET['sx']."&sy=".$_GET['sy'];
149                }
150                else {
151                        $finalSrc = $_GET['id'];
152                }
153                if (isset($_GET['url']))
154                        $url = $_GET['url']."&post=".$_GET['post'];
155        ?>
156                <div id="testWrap" style="z-index:1;">
157                        <img src="<?php echo $finalSrc; ?>" alt="test image" id="testImage" onload="javascript: document.getElementById('freshpostProgressBar').style.display = 'none';" />
158                </div>
159
160<?php
161
162$j = 0;
163foreach(explode("&", $finalSrc) as $item)
164{
165        if($j++ == 0)
166                continue;
167        $cropValueArr = explode("=",$item);
168?>
169        <input type="hidden" name="cropValues<?php echo $j; ?>" id="cropValues<?php echo $j; ?>" value="<?php echo $cropValueArr[1]; ?>" />
170<?php } ?>
171
172                <input type="hidden" name="sourceImage" id="sourceImage" value="<?php echo $finalSrc; ?>" />
173                <input type="hidden" name="url" id="url" value="<?php echo $url; ?>" />
174                <input type="hidden" name="tempSrc" id="tempSrc" />
175
176                <input type="hidden" name="imageThumbId" id="imageThumbId" value="<?php echo $_GET['imageThumbId']; ?>"/>
177
178                <p align="right" style="position:fixed; top:-10px; right:0px; z-index:1000;">
179                        <input type="button" value="Crop It" onclick="javascript: imageCrop();" />
180                </p>
181                <input type="hidden" name="x1" id="x1" />
182                <input type="hidden" name="y1" id="y1" />
183                <input type="hidden" name="x2" id="x2" />
184                <input type="hidden" name="y2" id="y2" />
185                <input type="hidden" name="width" id="width" />
186                <input type="hidden" name="height" id="height" />
187        </form>
188</body>
189</html>
Note: See TracBrowser for help on using the browser.