Plugin Directory

Changeset 1451249


Ignore:
Timestamp:
07/08/2016 11:16:56 AM (10 years ago)
Author:
tushov
Message:
  • Fixed banner editing
  • Added support for using Flash (swf) as banners
  • Added the ability to specify the size of the banner in its settings
Location:
banman/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • banman/trunk/banman.php

    r1448815 r1451249  
    3434add_action( 'admin_enqueue_scripts', array('BanMan', 'loadJSCSSAdmin') );
    3535add_action( 'wp_enqueue_scripts', array('BanMan', 'loadJSCSSSite') );
     36add_filter( 'upload_mimes', array('BanMan', 'addUploadMimes'));
    3637add_action( 'widgets_init', function () {
    3738    register_widget("BanManWidget");
     
    7778                $out .= $_banner['code'];
    7879            } else { // file
    79                 if ($_banner['url']) {
    80                     $out .= '<a href="' . $_banner['url'] . '"';
    81                     if (!$_banner['params']['nofollow']) $out .= ' rel="nofollow"';
    82                     if (!$_banner['params']['blank']) $out .= ' target="_blank"';
    83                     if ($_banner['params']['on_count_click']) $out .= ' onclick="jQuery.get(\'/?bman_click_id=\' + ' . $_banner['id'] . ')"';
    84                     $out .= '>';
    85                 }
    86                 $out .= '<img src="' . wp_get_attachment_image_url($_banner['attach_id'], 'large') . '" />';
    87                 if ($_banner['url']) $out .= '</a>';     
     80                $pathFile = get_attached_file($_banner['attach_id'], false);
     81                if (strtolower(pathinfo($pathFile, PATHINFO_EXTENSION))=='swf') {
     82                    $swfPath = wp_get_attachment_url($_banner['attach_id']);
     83                    $out .= $_banner['url'] ? '<div style="position:relative;">' : '<div>';
     84                    $wh = ($_banner['params']['height'] ? " height=\"{$_banner['params']['height']}\"" : '') . ($_banner['params']['width'] ? " width=\"{$_banner['params']['width']}\"" : '');
     85                    if ($_banner['url']) {
     86                        $out .= '<a href="' . $_banner['url'] . '"';
     87                        if (!$_banner['params']['nofollow']) $out .= ' rel="nofollow"';
     88                        if (!$_banner['params']['blank']) $out .= ' target="_blank"';
     89                        if ($_banner['params']['on_count_click']) $out .= ' onclick="jQuery.get(\'/?bman_click_id=\' + ' . $_banner['id'] . ')"';
     90                        if ($wh) $out .= ' style="position:absolute;top:0;left:0;z-index:99999;display:block;' . str_replace('"', '', str_replace(' ', 'px;', str_replace('=', ':', trim($wh)))) . 'px;"';
     91                        $out .= '></a>';
     92                    }
     93                    $out .= '<object' . $wh . '><param name="movie" value="' . $swfPath . '"><embed src="' . $swfPath . '"' . $wh . '></embed></object>';
     94                    $out .= '</div>';
     95                } else {
     96                    if ($_banner['url']) {
     97                        $out .= '<a href="' . $_banner['url'] . '"';
     98                        if (!$_banner['params']['nofollow']) $out .= ' rel="nofollow"';
     99                        if (!$_banner['params']['blank']) $out .= ' target="_blank"';
     100                        if ($_banner['params']['on_count_click']) $out .= ' onclick="jQuery.get(\'/?bman_click_id=\' + ' . $_banner['id'] . ')"';
     101                        $out .= '>';
     102                    }
     103                    $wh = ($_banner['params']['height'] ? " height=\"{$_banner['params']['height']}\"" : '') . ($_banner['params']['width'] ? " width=\"{$_banner['params']['width']}\"" : '');
     104                    $out .= '<img src="' . wp_get_attachment_image_url($_banner['attach_id'], 'large') . '"' . $wh . ' />';
     105                    if ($_banner['url']) $out .= '</a>';   
     106                } 
    88107            }
    89108            $out .= '</div>';     
     
    97116    'body-bg'=>__('Background banner page', 'banman'),
    98117));
     118
  • banman/trunk/includes/banman.class.php

    r1448815 r1451249  
    1111       
    1212        add_submenu_page('banman.php', __('Add new','banman'), __('Add new','banman'), 'manage_categories', 'edit', array('BanMan', 'edit'));
     13    }
     14   
     15    function addUploadMimes($mimes)
     16    {
     17        $mimes['swf'] = 'application/x-shockwave-flash';
     18        return $mimes;
    1319    }
    1420   
     
    7783                'publish'=>$row['publish']
    7884            ),
    79             array('id'=>$_GET['id'])
     85            array('id'=>$row['id'])
    8086        );
    8187       
     
    308314
    309315   
    310     function uploader( $name, $attach_id = '') {
    311         if ($attach_id) {
    312             $image_src = wp_get_attachment_image_url($attach_id, 'large');
     316    function uploader( $name, $row) {
     317        echo '<div id="uploader-box">
     318        <div>
     319        ';
     320        if ($row['attach_id']) {
     321            $pathFile = get_attached_file($row['attach_id'], false);
     322            $ext = strtolower(pathinfo($pathFile, PATHINFO_EXTENSION));
     323            if ($ext=='swf') {
     324                $swfPath = wp_get_attachment_url($row['attach_id']);
     325                $wh = ($row['params']['height'] ? " height=\"{$row['params']['height']}\"" : '') . ($row['params']['width'] ? " width=\"{$row['params']['width']}\"" : '');
     326                echo '<object' . $wh . '><param name="movie" value="' . $swfPath . '"><embed src="' . $swfPath . '"' . $wh . '></embed></object>';
     327            } else {
     328                $image_src = wp_get_attachment_image_url($row['attach_id'], 'large');
     329                echo '<img' . ($image_src ? " src=\"$image_src\"" : '') . ' />';
     330            }
    313331        }
    314332        echo '
    315         <div>
    316             <img' . ($image_src ? " src=\"$image_src\"" : '') . ' />
    317             <div>
    318                 <input type="hidden" name="' . $name . '" id="' . $name . '" value="' . $attach_id . '" />
    319                 <button type="submit" class="upload_image_button button">' . __('Upload','banman') . '</button>
    320             </div>
    321333        </div>
    322         ';
     334        <input type="hidden" name="' . $name . '" id="' . $name . '" value="' . $row['attach_id'] . '" />
     335        <button type="submit" class="upload_image_button button">' . __('Upload','banman') . '</button>
     336        </div>';
    323337    } 
    324338   
  • banman/trunk/languages/banman-ru_RU.po

    r1448815 r1451249  
    22msgstr ""
    33"Project-Id-Version: banman\n"
    4 "POT-Creation-Date: 2016-06-29 10:36+0300\n"
    5 "PO-Revision-Date: 2016-07-02 18:27+0300\n"
     4"POT-Creation-Date: 2016-07-08 14:10+0300\n"
     5"PO-Revision-Date: 2016-07-08 14:11+0300\n"
    66"Last-Translator: \n"
    77"Language-Team: Leonid Tushov <[email protected]>\n"
     
    1818"X-Poedit-SearchPath-0: .\n"
    1919
    20 #: banman.php:111
     20#: banman.php:115
    2121msgid "Pop-up banner"
    2222msgstr "Pop-up баннер"
    2323
    24 #: banman.php:112
     24#: banman.php:116
    2525msgid "Background banner page"
    2626msgstr "Баннер как фон страницы"
     
    115115msgstr "Выбрать позицию"
    116116
    117 #: includes/admin.list_table.php:138
     117#: includes/admin.list_table.php:139
    118118msgid "Filter"
    119119msgstr "Фильтр"
     
    127127msgstr "Список баннеров"
    128128
    129 #: includes/banman.class.php:11 tmpl/admin.php:4
     129#: includes/banman.class.php:12 tmpl/admin.php:4
    130130msgid "Add new"
    131131msgstr "Добавить новый"
    132132
    133 #: includes/banman.class.php:70
     133#: includes/banman.class.php:51
     134msgid "The new banner is created successfully!"
     135msgstr "Новый баннер успешно создан!"
     136
     137#: includes/banman.class.php:53
     138msgid "Failed to create a banner!"
     139msgstr "Ошибка создания баннера!"
     140
     141#: includes/banman.class.php:89
     142msgid "Banner successfully changed"
     143msgstr "Баннер успешно изменен"
     144
     145#: includes/banman.class.php:91
     146msgid "Error editing banner!"
     147msgstr "Ошибка редактирования баннера"
     148
     149#: includes/banman.class.php:139
    134150msgid "Close this banner?"
    135151msgstr "Закрыть данный баннер?"
    136152
    137 #: includes/banman.class.php:200
    138 msgid "Banner successfully changed"
    139 msgstr "Баннер успешно изменен"
    140 
    141 #: includes/banman.class.php:203
    142 msgid "Error editing banner!"
    143 msgstr "Ошибка редактирования баннера"
    144 
    145 #: includes/banman.class.php:240
    146 msgid "The new banner is created successfully!"
    147 msgstr "Новый баннер успешно создан!"
    148 
    149 #: includes/banman.class.php:243
    150 msgid "Failed to create a banner!"
    151 msgstr "Ошибка создания баннера!"
    152 
    153 #: includes/banman.class.php:262
     153#: includes/banman.class.php:252
    154154msgid "Selected banners successfully removed!"
    155155msgstr "Выбранные баннеры успешно удалены!"
    156156
    157 #: includes/banman.class.php:264
     157#: includes/banman.class.php:254
    158158msgid "Failed to delete the selected banners"
    159159msgstr "Ошибка удаления выбранных баннеров"
    160160
    161 #: includes/banman.class.php:277
     161#: includes/banman.class.php:266
    162162msgid "Selected banner successfully published"
    163163msgstr "Выбранные баннеры успешно включены"
    164164
    165 #: includes/banman.class.php:279
     165#: includes/banman.class.php:268
    166166msgid "Error publishing selected banners!"
    167167msgstr "Ошибка включения выбранных баннеров!"
    168168
    169 #: includes/banman.class.php:292
     169#: includes/banman.class.php:280
    170170msgid "Selected banner successfully unpublished!"
    171171msgstr "Выбранные баннеры успешно выключены!"
    172172
    173 #: includes/banman.class.php:294
     173#: includes/banman.class.php:282
    174174msgid "Error removing from the publication of selected banners"
    175175msgstr "Ошибка выключения выбранных баннеров"
    176176
    177 #: includes/banman.class.php:307
     177#: includes/banman.class.php:294
    178178msgid "For a selected number of views banners dropped"
    179179msgstr "Для выбранных баннеров кол-во показов успешно сброшено"
    180180
    181 #: includes/banman.class.php:309 includes/banman.class.php:324
     181#: includes/banman.class.php:296 includes/banman.class.php:310
    182182msgid "Error"
    183183msgstr "Ошибка"
    184184
    185 #: includes/banman.class.php:322
     185#: includes/banman.class.php:308
    186186msgid "For selected banners count clicks reset!"
    187187msgstr "Для выбранных баннеров сброшено кол-во кликов!"
    188188
    189 #: includes/banman.class.php:340
     189#: includes/banman.class.php:335
    190190msgid "Upload"
    191191msgstr "Загрузка"
     
    260260
    261261#: tmpl/edit.php:54
     262msgid "Width (px)"
     263msgstr "Ширина (px)"
     264
     265#: tmpl/edit.php:60
     266msgid "Height (px)"
     267msgstr "Высота (px)"
     268
     269#: tmpl/edit.php:66
    262270msgid "Enable banner"
    263271msgstr "Включить баннер"
    264272
    265 #: tmpl/edit.php:56 tmpl/edit.php:79 tmpl/edit.php:86
     273#: tmpl/edit.php:68 tmpl/edit.php:91 tmpl/edit.php:98
    266274msgid "Yes"
    267275msgstr "Да"
    268276
    269 #: tmpl/edit.php:57 tmpl/edit.php:80 tmpl/edit.php:87
     277#: tmpl/edit.php:69 tmpl/edit.php:92 tmpl/edit.php:99
    270278msgid "No"
    271279msgstr "Нет"
    272280
    273 #: tmpl/edit.php:72
     281#: tmpl/edit.php:84
    274282msgid "Advanced settings"
    275283msgstr "Расширенные настройки"
    276284
    277 #: tmpl/edit.php:77
     285#: tmpl/edit.php:89
    278286msgid "Prevent indexing links"
    279287msgstr "Предотвратить индексирование ссылки"
    280288
    281 #: tmpl/edit.php:84
     289#: tmpl/edit.php:96
    282290msgid "Open links in new window"
    283291msgstr "Открывать ссылку в новом окне"
    284292
    285 #: tmpl/edit.php:91
     293#: tmpl/edit.php:103
    286294msgid "Include statistics for"
    287295msgstr "Включить статистику для"
    288296
    289 #: tmpl/edit.php:93
     297#: tmpl/edit.php:105
    290298msgid "shows"
    291299msgstr "показов"
    292300
    293 #: tmpl/edit.php:94
     301#: tmpl/edit.php:106
    294302msgid "clicks"
    295303msgstr "кликов"
    296304
    297 #: tmpl/edit.php:101
     305#: tmpl/edit.php:113
    298306msgid "Save"
    299307msgstr "Сохранить"
    300308
    301 #: tmpl/edit.php:101
     309#: tmpl/edit.php:113
    302310msgid "Save changes"
    303311msgstr "Сохранить изменения"
  • banman/trunk/readme.txt

    r1448815 r1451249  
    55Requires at least: 4.4.0
    66Tested up to: 4.5.2
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2
    99
    10 Simple and easy to use banner management system on the site.
     10Простой и удобный плагин для управления баннерами на сайте. Simple and easy to use banner management system on the site.
    1111
    1212== Description ==
     
    1717= Возможности =
    1818
    19 * В качестве баннеров можно использовать любые изображения в форматах: JPEG, PNG, GIF (+ Animated GIF)
     19* В качестве баннеров можно использовать любые изображения в форматах: JPEG, PNG, GIF (+ Animated GIF), а также Flash (SWF).
    2020* Также в качестве баннера можно использовать код (html, javascript, css)
    2121* Имеется возможность задавать диапазон отображения баннера на сайте  ( с определенной начальной по конечную дату ).
     
    115115= 1.00 =
    116116* Initial release
     117
     118= 1.1 =
     119* Fixed banner editing
     120* Added support for using Flash (swf) as banners
     121* Added the ability to specify the size of the banner in its settings
  • banman/trunk/tmpl/edit.php

    r1448815 r1451249  
    3434<tr id="banner_file" class="form-field form-required"<?php echo $row['type'] ? ' style="display:none;"' : ''; ?>>
    3535    <th scope="row"><label><?php _e('File banner','banman'); ?></label></th>
    36     <td><?php BanMan::uploader('attach_id', $row['attach_id']); ?></td>
     36    <td><?php BanMan::uploader('attach_id', $row); ?></td>
    3737</tr>
    3838<tr id="banner_code" class="form-field form-required"<?php echo $row['type'] ? '' : ' style="display:none;"'; ?>>
     
    4949        <?php _e('from','banman'); ?> <input type="text" class="datepick" name="row[show_start]" value="<?php echo $row['show_start'] ? date('d.m.Y', strtotime($row['show_start'])) : date('d.m.Y'); ?>" size="10" style="width:auto;" />
    5050         <?php _e('to','banman'); ?> <input type="text" class="datepick" name="row[show_end]" value="<?php echo ($row['show_end']=='0000-00-00' or $row['show_end']=='') ? '' : date('d.m.Y', strtotime($row['show_end'])); ?>" size="10" style="width:auto;" />
     51    </td>
     52</tr>
     53<tr class="form-field">
     54    <th scope="row"><label><?php _e('Width (px)','banman'); ?></label></th>
     55    <td>
     56        <input type="text" name="row[params][width]" value="<?php echo $row['params']['width']; ?>" style="width: 60px;" />
     57    </td>
     58</tr>
     59<tr class="form-field">
     60    <th scope="row"><label><?php _e('Height (px)','banman'); ?></label></th>
     61    <td>
     62        <input type="text" name="row[params][height]" value="<?php echo $row['params']['height']; ?>" style="width: 60px;" />
    5163    </td>
    5264</tr>
     
    101113<?php submit_button($isNew ? __('Save', 'banman') : __('Save changes', 'banman'),'primary'); ?>
    102114<input type="hidden" name="action" value="<?php echo $isNew ? 'addSave' : 'editSave'; ?>" />
     115<input type="hidden" name="row[id]" value="<?php echo $row['id']; ?>" />
    103116</form>
    104117</div>
     
    128141        var button = jQuery(this);
    129142        wp.media.editor.send.attachment = function(props, attachment) {
    130             jQuery(button).parent().prev().attr('src', attachment.url);
    131             jQuery(button).prev().val(attachment.id);
     143            var fileUrl = attachment.url, parts, ext = ( parts = fileUrl.split("/").pop().split(".") ).length > 1 ? parts.pop() : "";
     144            if (ext=='swf') {
     145                var html = '<object><param name="movie" value="' + attachment.url + '"><embed src="' + attachment.url + '"></embed></object>';
     146            } else {
     147                var html = '<img src="' + attachment.url + '" />';
     148            }
     149            jQuery('#uploader-box div').html(html);
     150            jQuery('#attach_id').val(attachment.id);
    132151            wp.media.editor.send.attachment = send_attachment_bkp;
    133152        }
Note: See TracChangeset for help on using the changeset viewer.