Plugin Directory

Changeset 510077


Ignore:
Timestamp:
02/24/2012 08:14:01 PM (14 years ago)
Author:
Strunker
Message:

Minor enhancements on first configuration

Location:
polizeipresse/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • polizeipresse/trunk/Polizeipresse.php

    r509517 r510077  
    33 Plugin Name: Polizeipresse Plugin
    44 Plugin URI: http://wordpress.org/extend/plugins/polizeipresse/
    5  Description: The plugin loads police news from German police stations and shows them in your blog.
     5 Description: The plugin loads police news from German police offices and shows them in your blog.
    66 Version: 0.2
    77 Author: Karsten Strunk
  • polizeipresse/trunk/admin.php

    r509517 r510077  
    1212
    1313        if (empty($api_key) || empty($office_id)) {
    14             print ('<div id="message" class="error">' . __('Polizeipresse plugin: Please enter API key and office id', 'Polizeipresse') . '</div>');
     14            print ('<div id="message" class="error">' . __('Polizeipresse plugin: Please enter API key select police office', 'Polizeipresse') . '</div>');
    1515        }
    1616    }
     
    172172                    <td>
    173173                        <?php $api_key = polizeipresse_get_option(POLIZEIPRESSE_API_KEY); ?>
    174                         <input name="api_key" size="50" value="<?php echo $api_key; ?>" type="text" class="regular-text" />
     174                        <input name="api_key" id="api_key" size="50" value="<?php echo $api_key; ?>" type="text" class="regular-text" />
    175175                    </td>
    176176                </tr>
     
    342342            </div>
    343343
    344             <p>
    345                 <label for="office_search"><?php _e('Search terms', 'Polizeipresse'); ?>:</lable>
    346                 <input id="office_search_terms" size="30" type="text" class="regular-text"
    347                     value="<?php echo polizeipresse_get_option(POLIZEIPRESSE_OFFICE_NAME); ?>" />
    348             </p>
    349 
    350             <p style="text-align: center;">
    351                 <button id="searchOfficeButton" class="button-primary">
    352                     <?php _e('Search', 'Polizeipresse'); ?>
    353                 </button>
    354                 <button id="cancelSearchOfficeDialog" class="button-primary"><?php _e('Cancel', 'Polizeipresse'); ?></button>
    355             </p>
     344            <form>
     345                <p>
     346                    <label for="office_search"><?php _e('Search terms', 'Polizeipresse'); ?>:</lable>
     347                    <input id="office_search_terms" size="30" type="text" class="regular-text"
     348                        value="<?php echo polizeipresse_get_option(POLIZEIPRESSE_OFFICE_NAME); ?>" />
     349                </p>
     350
     351                <p style="text-align: center;">
     352                    <button id="searchOfficeButton" class="button-primary">
     353                        <?php _e('Search', 'Polizeipresse'); ?>
     354                    </button>
     355                    <button id="cancelSearchOfficeDialog" class="button-primary"><?php _e('Cancel', 'Polizeipresse'); ?></button>
     356                </p>
     357            </form>
    356358
    357359            <div id="searchOfficeResult" style="display: none;">
     
    415417
    416418    $terms = trim($_POST['terms']);
     419
    417420    $api_key = polizeipresse_get_option(POLIZEIPRESSE_API_KEY);
     421    if (empty($api_key)) {
     422        // If api key is not in database, use api_key from request
     423        $api_key = trim($_POST['api_key']);
     424    };
    418425
    419426    if (!empty ($terms) && !empty ($api_key)) {
     
    432439    }
    433440
     441    // Return reponse
    434442    echo json_encode($result);
    435443
  • polizeipresse/trunk/i18n/Polizeipresse-de_DE.po

    r508487 r510077  
    33"Project-Id-Version: Polizeipresse\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2012-02-21 21:45+0100\n"
    6 "PO-Revision-Date: 2012-02-21 21:45+0100\n"
     5"POT-Creation-Date: 2012-02-24 20:29+0100\n"
     6"PO-Revision-Date: 2012-02-24 20:29+0100\n"
    77"Last-Translator: Karsten Strunk <karsten@strunk.eu>\n"
    88"Language-Team: Karsten Strunk <karsten@strunk.eu>\n"
     
    1616
    1717#: admin.php:14
    18 msgid "Polizeipresse plugin: Please enter API key and office id"
    19 msgstr "Polizeipresse plugin: Bitte API-Schlüssel und Dienststellen-Id eingeben."
    20 
    21 #: admin.php:101
     18msgid "Polizeipresse plugin: Please enter API key select police office"
     19msgstr "Polizeipresse plugin: Bitte API-Schlüssel eingeben und Dienststellen auswählen."
     20
     21#: admin.php:105
    2222msgid "Your settings have been saved."
    2323msgstr "Ihre Einstellungen wurden gespeichert."
    2424
    25 #: admin.php:110
     25#: admin.php:114
    2626msgid "Stories have been loaded."
    2727msgstr "Meldungen wurden geladen."
    2828
    29 #: admin.php:121
     29#: admin.php:125
    3030msgid "Last processed story id has been reset."
    3131msgstr "Zuletzt verarbeitete Meldungs-ID wurde zurückgesetzt."
    3232
    33 #: admin.php:146
    34 msgid "API key is required"
    35 msgstr "API-Schlüssel wird benötigt."
    36 
    37 #: admin.php:147
    38 msgid "Office id is required and must be numerical"
    39 msgstr "Numerisch Dienststellen-ID wird benötigt"
    40 
    41 #: admin.php:173
     33#: admin.php:144
    4234msgid "Options"
    4335msgstr "Optionen"
    4436
    45 #: admin.php:178
     37#: admin.php:149
    4638msgid "General"
    4739msgstr "Allgemein"
    4840
    49 #: admin.php:179
     41#: admin.php:150
    5042msgid "Filter"
    5143msgstr "Filter"
    5244
    53 #: admin.php:180
     45#: admin.php:151
    5446msgid "Cronjob"
    5547msgstr "Cronjob"
    5648
    57 #: admin.php:189
     49#: admin.php:160
    5850msgid "This page contains fundamental plugin settings. Without API key and office id the plugin is unable to work."
    59 msgstr "Auf dieser Seite legen Sie grundlegende Einstellungen des Plugins fest. Ohne API-Schlüssel und Dienststellen-ID funktioniert das Plugin nicht."
    60 
    61 #: admin.php:191
     51msgstr "Auf dieser Seite legen Sie grundlegende Einstellungen des Plugins fest. Ohne API-Schlüssel und ausgewählte Dienststelle funktioniert das Plugin nicht."
     52
     53#: admin.php:162
    6254msgid "If you do not have an API key, please register on the following page to get one"
    6355msgstr "Wenn Sie noch keinen API-Schlüssel haben, können Sie diesen auf der folgenden Seite bekommen"
    6456
    65 #: admin.php:192
    66 #: admin.php:194
     57#: admin.php:163
    6758msgid "Click here"
    6859msgstr "Hier clicken"
    6960
    70 #: admin.php:193
    71 msgid "You will find the required office id on this site"
    72 msgstr "Die Dienststellen-ID für die gewünschte Dienststelle finden Sie auf folgender Seite"
    73 
    74 #: admin.php:201
     61#: admin.php:170
    7562msgid "Polizeipresse API key"
    7663msgstr "Polizeipresse API-Schlüssel"
    7764
    78 #: admin.php:210
    79 msgid "Office id"
    80 msgstr "Dienststellen-ID"
    81 
    82 #: admin.php:225
     65#: admin.php:180
     66msgid "Police office"
     67msgstr "Polizeidienststelle"
     68
     69#: admin.php:188
     70#: admin.php:337
     71msgid "Search for offices"
     72msgstr "Nach Polizeistationen suchen"
     73
     74#: admin.php:201
    8375msgid "On this page you can define filters. These filteres are used to filter police stories. Multiple filters can be separated by comma."
    8476msgstr "Auf dieser Seite können Sie Filter definieren. Diese Filter werden verwendet, um Polizeimeldungen zu filtern. Mehrere Filter können durch Komma getrennt werden."
    8577
    86 #: admin.php:232
     78#: admin.php:208
    8779msgid "Positive filters"
    8880msgstr "Positive Filter"
    8981
    90 #: admin.php:233
    91 #: admin.php:244
     82#: admin.php:209
     83#: admin.php:220
    9284msgid "Separate multiple filters by comma."
    9385msgstr "Mehrere Filter durch Komma trennen"
    9486
    95 #: admin.php:243
     87#: admin.php:219
    9688msgid "Negative filters"
    9789msgstr "Negative Filter"
    9890
    99 #: admin.php:260
     91#: admin.php:236
    10092msgid "New police stories can be automatically loaded and added to your blog. This is done every hour."
    10193msgstr "Neue Polizeimeldungen können automatisch abgefragt und zu Ihrem Blog hinzugefügt werden. Die Abfrage geschieht stündlich."
    10294
    103 #: admin.php:267
     95#: admin.php:243
    10496msgid "Enable cronjob"
    10597msgstr "Cronjob einschalten"
    10698
    107 #: admin.php:276
     99#: admin.php:252
    108100msgid "User for new posts"
    109101msgstr "Benutzer für neue Artikel"
    110102
    111 #: admin.php:288
     103#: admin.php:264
    112104msgid "Category for new posts"
    113105msgstr "Kategorie für neue Artikel"
    114106
    115 #: admin.php:300
     107#: admin.php:276
    116108msgid "Publish new posts immediately"
    117109msgstr "Neue Meldungen sofort veröffentlichen"
    118110
    119 #: admin.php:309
     111#: admin.php:285
    120112msgid "Notify on new stories"
    121113msgstr "Alarmierung bei neuen Meldungen"
    122114
    123 #: admin.php:318
     115#: admin.php:294
    124116msgid "Last processed story id"
    125117msgstr "Letzte verarbeitete Meldungs-ID"
    126118
    127 #: admin.php:327
    128 #: admin.php:335
     119#: admin.php:303
     120#: admin.php:311
    129121msgid "unknown"
    130122msgstr "unbekannt"
    131123
    132 #: admin.php:335
     124#: admin.php:311
    133125msgid "Date/time"
    134126msgstr "Datum/Uhrzeit"
    135127
    136 #: admin.php:335
     128#: admin.php:311
    137129msgid "State"
    138130msgstr "Status"
    139131
    140 #: admin.php:335
     132#: admin.php:311
    141133msgid "successfull"
    142134msgstr "erfolgreich"
    143135
    144 #: admin.php:342
     136#: admin.php:318
    145137msgid "Load stories now"
    146138msgstr "Jetzt neue Meldungen laden"
    147139
    148 #: admin.php:343
     140#: admin.php:320
    149141msgid "Reset last processed story id"
    150142msgstr "Zuletzt verarbeitete Meldungs-ID zurücksetzen"
    151143
    152 #: admin.php:352
     144#: admin.php:329
    153145msgid "Save all"
    154146msgstr "Alles speichern"
     147
     148#: admin.php:341
     149msgid "You can search for German police offices here. Start the search and select one item from the result list. Press apply to accept."
     150msgstr "Sie können hier nach deutschen Polizeidienststellen suchen. Nach der Suche wählen sie eine Dienststelle aus und drücken 'übernehmen'."
     151
     152#: admin.php:345
     153msgid "Search terms"
     154msgstr "Suche"
     155
     156#: admin.php:352
     157msgid "Search"
     158msgstr "Suchen"
     159
     160#: admin.php:354
     161msgid "Cancel"
     162msgstr "Abbrechen"
     163
     164#: admin.php:360
     165msgid "Search result"
     166msgstr "Suchergebnis"
     167
     168#: admin.php:364
     169msgid "Apply"
     170msgstr "Übernehmen"
    155171
    156172#: Polizeipresse.php:294
     
    213229msgstr "Stunden"
    214230
     231#~ msgid "API key is required"
     232#~ msgstr "API-Schlüssel wird benötigt."
     233
     234#~ msgid "Office id is required and must be numerical"
     235#~ msgstr "Numerisch Dienststellen-ID wird benötigt"
     236
     237#~ msgid "You will find the required office id on this site"
     238#~ msgstr ""
     239#~ "Die Dienststellen-ID für die gewünschte Dienststelle finden Sie auf "
     240#~ "folgender Seite"
     241
     242#~ msgid "Office id"
     243#~ msgstr "Dienststellen-ID"
  • polizeipresse/trunk/js/admin.js

    r509518 r510077  
    6060function polizeipresse_admin_init_search_dialog() {
    6161
    62     // Button for opening the search dialog
     62    // Define button for opening the search dialog
    6363    jQuery("#searchDialogButton").click(function(){
    64         jQuery("#searchDialog").dialog({
    65             closeOnEscape: true,
    66             modal: true,
    67             width: 500,
    68             dialogClass: 'wp-dialog',
    69         });
     64        api_key = jQuery('#api_key').val();
     65        if (api_key) {
     66            jQuery("#searchDialog").dialog({
     67                closeOnEscape: true,
     68                modal: true,
     69                width: 500,
     70                dialogClass: 'wp-dialog',
     71            });
     72        }
    7073        return false;
     74    });
     75
     76    // Enable search dialog button only if api_key is set
     77    jQuery("#api_key").keyup(function(){
     78        api_key = jQuery("#api_key").val();
     79        if (api_key) {
     80            jQuery("#searchDialogButton").removeAttr("disabled");
     81        }
     82        else {
     83            jQuery("#searchDialogButton").attr("disabled", "disabled");
     84        }
     85        return true;
    7186    });
    7287
     
    7691            jQuery("#searchDialogButton").click();
    7792        }
     93        return true;
    7894    });
    7995
     
    87103    jQuery("#searchOfficeButton").click(function(){
    88104
     105        // Disable search button
     106        jQuery("#searchOfficeButton").attr("disabled", "disabled");
     107
    89108        // Hide result list
    90109        jQuery("#searchOfficeResult").hide();
     
    95114                action: 'polizeipresse_search_office',
    96115                terms: jQuery('#office_search_terms').val(),
     116                api_key: jQuery('#api_key').val(),
    97117            },
    98118            polizeipresse_admin_handle_search_result
     
    118138
    119139function polizeipresse_admin_handle_search_result(response, textStatus) {
    120     try {
    121         var offices = JSON.parse(response);
     140    if (response && response.length > 0) {
     141        try {
     142            var offices = JSON.parse(response);
    122143
    123         // Add offices to result list
    124         jQuery("#officeSelector").empty();
    125         jQuery.each(offices, function(index, office) {
    126                     jQuery("<option/>").val(office.id).text(office.name).appendTo("#officeSelector");
    127         });
    128         jQuery("#officeSelector option:first").attr("selected", "selected");
     144            // Add offices to result list
     145            jQuery("#officeSelector").empty();
     146            jQuery.each(offices, function(index, office) {
     147                        jQuery("<option/>").val(office.id).text(office.name).appendTo("#officeSelector");
     148            });
     149            jQuery("#officeSelector option:first").attr("selected", "selected");
    129150
    130         // Show result list
    131         jQuery("#searchOfficeResult").show();
     151            // Show result list
     152            jQuery("#searchOfficeResult").show();
     153        }
     154        catch(e) {
     155            // TODO Handle error
     156            alert("An error occurred: " + e);
     157        }
    132158    }
    133     catch(e) {
     159    else {
    134160        // TODO Handle error
    135         alert(e);
     161        alert("No result from server. Please check api key and/or connection.");
    136162    }
     163
     164    // Enable search button
     165    jQuery("#searchOfficeButton").removeAttr("disabled");
    137166}
Note: See TracChangeset for help on using the changeset viewer.