zachis.it-m /wp-contentold/plugins/shashin/Admin/Display/mediaPhotos.php

Language PHP Lines 233
MD5 Hash ef0a310e07bfd4671a954a37a1cf2ee1 Estimated Cost $1,041 (why?)
Repository https://bitbucket.org/zachisit/zachis.it-m.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<script type="text/javascript">
jQuery(document).ready(function($) {
    function shashinLoadPhotos() {
        $('#shashinMediaMenuLoading').show();
        var adminAjaxUrl = '<?php echo admin_url("admin-ajax.php"); ?>';
        var filterRoot = $('#shashinMediaMenuFilter').get();
        var albumId = $('#shashinFilterAlbum', filterRoot).val();
        var order = $('#shashinFilterOrder', filterRoot).val();
        var reverse = $('#shashinFilterReverse', filterRoot).attr('checked') ? 'y' : 'n';
        var page = shashinGetCurrentPage();
        var dataToSend = {
            action: 'shashinGetPhotosForMediaMenu',
            shashinAlbumId: albumId,
            shashinOrder: order,
            shashinReverse: reverse,
            shashinPage: page
        };

        $.post(adminAjaxUrl, dataToSend, function(dataReceived) {
            $('#shashinMediaMenuPhotoGrid img').remove();
            $('#shashinMediaMenuNav span').text(dataReceived['page'] + '/' + dataReceived['totalPages']);
            for (i in dataReceived['photos']) {
                var imgTag = shashinWriteImgTag(
                    'shashinMediaMenuThumb_' + dataReceived['photos'][i]['id'],
                    dataReceived['photos'][i]['contentUrl'] + '?imgmax=72&crop=1',
                    dataReceived['photos'][i]['description'],
                    72,
                    72
                );
                $('#shashinMediaMenuPhotoGrid').append(imgTag);
            }
            $('#shashinMediaMenuLoading').hide();
        }, 'json');
    }

    function shashinWriteImgTag(id, src, description, width, height) {
        return '<img id="' + id + '"'
            + ' src="' + src + '"'
            + ' alt="' + description + '"'
            + ' title="' + description + '"'
            + ' width="' + width + '"'
            + ' height="' + height + '" />';
    }

    function shashinGetCurrentPage() {
        var page = $('#shashinMediaMenuNav span').text().split('/');
        page[0] = parseFloat(page[0]);
        page[1] = parseFloat(page[1]);
        return page[0];
    }

    function shashinGetTotalPages() {
        var page = $('#shashinMediaMenuNav span').text().split('/');
        page[0] = parseFloat(page[0]);
        page[1] = parseFloat(page[1]);
        return page[1];
    }

    $('#shashinMediaMenuSelectedPhotos img').live('click', function() {
        $(this).remove();
    })

    $('#shashinMediaMenuPhotoGrid img').live('mouseover', function(e) {
        var offset = $('#shashinMediaMenuPhotoGrid').offset();
        offset.left = offset.left + 2;
        offset.top = offset.top + 2;
        if (e.clientX < (offset.left + 304)) offset.left = offset.left + 304;
        var imgSrc = $(this).attr('src').replace('?imgmax=72&crop=1', '?imgmax=288'); // for Picasa
        imgSrc = imgSrc.replace('/mini/', '/thumb/'); // for Twitpic
        var imgTag = shashinWriteImgTag(
            'shashinMediaMenuThumbPreview_' + $(this).attr('id').replace('shashinMediaMenuThumb_', ''),
            imgSrc,
            $(this).attr('alt')
        )

        $('#shashinMediaMenuPhotoPreview')
            .html(imgTag)
            .css('top', offset.top)
            .css('left', offset.left)
            .show();
    })

    $('#shashinMediaMenuPhotoGrid img').live('mouseout', function() {
        $('#shashinMediaMenuPhotoPreview').hide();
    });

    $('#shashinMediaMenuPhotoGrid img').live('click', function() {
        var imgTag = shashinWriteImgTag(
            'shashinMediaMenuThumbSelected_' + $(this).attr('id').replace('shashinMediaMenuThumb_', ''),
            $(this).attr('src'),
            $(this).attr('alt'),
            $(this).attr('width'),
            $(this).attr('height')
        )
        $('#shashinMediaMenuSelectedPhotos').append(imgTag);
    });

    $('#shashinInsertShortcode').click(function() {
        var selectedIds = new Array;
        $('#shashinMediaMenuSelectedPhotos img').each(function() {
            selectedIds.push($(this).attr('id').replace('shashinMediaMenuThumbSelected_',''));
        });

        if (selectedIds.length == 0) return alert('<?php _e('No photos selected', 'shashin') ?>');
        parent.send_to_editor('[shashin type="photo"'
            + ' id="' + selectedIds.join(',') + '"'
            + ' size="' + $('#shashinSize').val() + '"'
            + ' columns="' + $('#shashinColumns').val() + '"'
            + ' order="user"'
            +  (($('#shashinCaption').val() == 'y') ? (' caption="' + $('#shashinCaption').val() + '"') : '')
            +  (($('#shashinPosition').val() == '') ? '' : (' position="' + $('#shashinPosition').val() + '"'))
            +  (($('#shashinCrop').val() == 'y') ? (' crop="' + $('#shashinCrop').val() + '"') : '')
            + ']'
        );
    });

    $('#shashinFilterUpdate').click(function() {
        shashinLoadPhotos();
    });

    $('#shashinPreviousPage').click(function() {
        page = shashinGetCurrentPage() - 1;
        totalPages = shashinGetTotalPages();
        if (page < 1) return;
        $('#shashinMediaMenuNav span').text(page + '/' + totalPages);
        shashinLoadPhotos();
    });

    $('#shashinNextPage').click(function() {
        page = shashinGetCurrentPage() + 1;
        totalPages = shashinGetTotalPages();
        if (page > totalPages) return;
        $('#shashinMediaMenuNav span').text(page + '/' + totalPages);
        shashinLoadPhotos();
    });

    shashinLoadPhotos();
})
</script>

<form id="shashinMediaMenu" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
    <div id="shashinMediaMenuFilter">
        <div><?php _e('Album', 'shashin') ?><br />
            <select style="width: 100px;" name="shashinFilterAlbum" id="shashinFilterAlbum">
                <option value="0"><?php _e('All albums', 'shashin') ?></option>
                <?php foreach ($albums as $album): ?>
                    <option value="<?php echo $album->id ?>"><?php echo $album->title ?></option>
                <?php endforeach ?>
            </select>
        </div>

        <div><?php _e('Order', 'shashin') ?><br />
            <select style="width: 100px" name="shashinFilterOrder" id="shashinFilterOrder">
                <option value="date"><?php _e('Date Taken', 'shashin') ?></option>
                <option value="id"><?php _e('Shashin ID', 'shashin') ?></option>
                <option value="filename"><?php _e('Filename', 'shashin') ?></option>
                <option value="source"><?php _e('Source order', 'shashin') ?></option>
            </select>
        </div>

        <div><?php _e('Reverse<br />order?', 'shashin') ?>
            <input type="checkbox" checked="checked" name="shashinFilterReverse" id="shashinFilterReverse" value="1" />
        </div>

        <div>&nbsp;<br />
            <input type="button" class="button" name="shashinFilterUpdate" id="shashinFilterUpdate" value="<?php _e('Update', 'shashin') ?>" />
        </div>

        <div id="shashinMediaMenuNav"><br />
            <input type="button" class="button" name="shashinPreviousPage" id="shashinPreviousPage" value="<?php _e('Previous', 'shashin') ?>" />
                <span>1/1</span>
            <input type="button" class="button" name="shashinNextPage" id="shashinNextPage" value="<?php _e('Next', 'shashin') ?>" />
        </div>
    </div>
    <div id="shashinMediaMenuLoading">
        <?php _e('Loading photos', 'shashin') ?>
        <img src="<?php echo $loaderUrl ?>" alt="Loading..." width="220" height="19" />
    </div>
    <div id="shashinMediaMenuPhotoPreview">&nbsp;</div>
    <div id="shashinMediaMenuPhotoGrid"></div>

    <div id="shashinMediaMenuSelectedPhotos"><h3><?php _e('Selected photos', 'shashin'); ?></h3></div>
    <div id="shashinMediaMenuShortcodeCriteria">
        <h3><?php _e('Shortcode attributes', 'shashin') ?></h3>
        <table id="shashinMediaMenuShortcodeCriteriaTable">
            <tbody>
                <tr>
                    <td><label for="shashinSize"><?php _e('Size', 'shashin') ?></label></td>
                    <td><select name="shashinSize" id="shashinSize">
                        <option value="xsmall"><?php _e('X-Small (72px)', 'shashin') ?></option>
                        <option value="small" selected="selected"><?php _e('Small (150px)', 'shashin') ?></option>
                        <option value="medium"><?php _e('Medium (300px)', 'shashin') ?></option>
                        <option value="large"><?php _e('Large (600px)', 'shashin') ?></option>
                        <option value="xlarge"><?php _e('X-Large (800px)', 'shashin') ?></option>
                        <option value="max"><?php _e('Max', 'shashin') ?></option>
                    </select></td>
                    <td><label for="shashinColumns"><?php _e('Columns', 'shashin') ?></label></td>
                    <td><select name="shashinColumns" id="shashinColumns">
                        <option value="max"><?php _e('Max', 'shashin'); ?></option>
                        <?php for ($i = 1; $i < 16; $i++) {
                            echo "<option value='$i'>$i</option>" . PHP_EOL;
                        } ?>
                    </select></td>
                </tr>
                <tr>
                    <td><label for="shashinCaption"><?php _e('Caption', 'shashin') ?></label></td>
                    <td><select name="shashinCaption" id="shashinCaption">
                        <option value="n"><?php _e('No', 'shashin'); ?></option>
                        <option value="y"><?php _e('Yes', 'shashin'); ?></option>
                    </select></td>
                    <td><label for="shashinPosition"><?php _e('Position', 'shashin') ?></label></td>
                    <td><select name="shashinPosition" id="shashinPosition">
                        <option value="center"><?php _e('Center', 'shashin'); ?></option>
                        <option value="left"><?php _e('Left', 'shashin'); ?></option>
                        <option value="right"><?php _e('Right', 'shashin'); ?></option>
                        <option value=""><?php _e('None', 'shashin'); ?></option>
                    </select></td>
                </tr>
                <tr>
                    <td><label for="shashinCrop"><?php _e('Crop', 'shashin') ?></label></td>
                    <td><select name="shashinCrop" id="shashinCrop">
                        <option value="n"><?php _e('No', 'shashin'); ?></option>
                        <option value="y"><?php _e('Yes', 'shashin'); ?></option>
                    </select></td>
                    <td colspan="2"><input type="button" class="button" name="shashinInsertShortcode" id="shashinInsertShortcode" value="<?php _e('Insert shortcode', 'shashin') ?>" /></td>
                </tr>
            </tbody>
        </table>
    </div>
</form>
Back to Top