Plugin Directory

Changeset 791815


Ignore:
Timestamp:
10/22/2013 02:50:55 PM (12 years ago)
Author:
Strunker
Message:

Separate categorie for each office added

Location:
polizeipresse/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • polizeipresse/trunk/Polizeipresse.php

    r788944 r791815  
    44 Plugin URI: http://wordpress.org/extend/plugins/polizeipresse/
    55 Description: The plugin loads police news from German police offices and shows them in your blog.
    6  Version: 0.3
     6 Version: 0.3a3
    77 Author: Karsten Strunk
    88 Author URI: http://www.strunk.eu/wordpress
     
    8282    }
    8383
     84    // Copy cron_add_categorie_id to default_category_id.
     85    $category_id_old = polizeipresse_get_option(POLIZEIPRESSE_CRON_ADD_CATEGORIE_ID);
     86    if ($category_id_old) {
     87        polizeipresse_update_option(POLIZEIPRESSE_DEFAULT_CATEGORY_ID, $category_id_old);
     88        polizeipresse_delete_option(POLIZEIPRESSE_CRON_ADD_CATEGORIE_ID);
     89    }
     90
    8491    //
    8592    // End migration
     
    194201                // Do we need to create a new post for this story?
    195202                if ($story_id > $last_story_id) {
    196                     polizeipresse_add_story($story);
     203                    polizeipresse_add_story($story, $office);
    197204                    $max_story_id = $story_id;
    198205                }
     
    318325/**
    319326 * Internal function: Creates a new post out of story.
    320  */
    321 function polizeipresse_add_story($story) {
     327 *
     328 * @param story Story to add
     329 * @param office Number of office
     330 */
     331function polizeipresse_add_story($story, $office) {
    322332
    323333    // Format text
     
    337347    $post_date = (empty($story->published) ? time() : strtotime($story->published));
    338348
    339     // Categorie
    340     $post_categorie = polizeipresse_get_option(POLIZEIPRESSE_CRON_ADD_CATEGORIE_ID);
     349    // Categorie. Use special category for office or default if none is defined.
     350    $post_category = polizeipresse_get_option(POLIZEIPRESSE_OFFICE_CATEGORY_ID . $office);
     351    if (empty($post_category) || $post_category == -1) {
     352        // Use default category
     353        $post_category = polizeipresse_get_option(POLIZEIPRESSE_DEFAULT_CATEGORY_ID);
     354    }
    341355
    342356    // User
     
    354368        'post_author' => $post_user,
    355369        'post_type' => 'post',
    356         'post_category' => array($post_categorie)
     370        'post_category' => array($post_category)
    357371    );
    358372    $post_id = wp_insert_post($new_post);
  • polizeipresse/trunk/admin.php

    r788210 r791815  
    4747
    4848        for($office = 0; $office < POLIZEIPRESSE_MAX_OFFICE_COUNT; $office++) {
     49
     50            // Id of office
    4951            $office_id = strip_tags($_POST['office_id' . $office]);
    5052            if (!empty($office_id)) {
     
    5658            }
    5759
     60            // Name of office
    5861            $office_name = strip_tags($_POST['office_name' . $office]);
    5962            if (!empty($office_name)) {
     
    6467                $options[POLIZEIPRESSE_CRON_LAST_STORY_ID . $office] = '';
    6568            }
     69
     70            // Category for office
     71            $office_category_id = strip_tags($_POST['office_category_id' . $office]);
     72            if (isset ($office_category_id)) {
     73                $options[POLIZEIPRESSE_OFFICE_CATEGORY_ID . $office] = $office_category_id;
     74            }
    6675        }
    6776
     
    92101        }
    93102
    94         if (isset ($_POST['cron_categorie_id'])) {
    95             $options[POLIZEIPRESSE_CRON_ADD_CATEGORIE_ID] = strip_tags($_POST['cron_categorie_id']);
     103        if (isset ($_POST['default_category_id'])) {
     104            $options[POLIZEIPRESSE_DEFAULT_CATEGORY_ID] = strip_tags($_POST['default_category_id']);
    96105        }
    97106
     
    194203
    195204                <tr valign="top">
    196                     <th scope="row">
     205                    <td scope="row" class="label">
    197206                        <label for="api_key"><?php _e('Polizeipresse API key', 'Polizeipresse'); ?>:</lable>
    198                     </th>
     207                    </td>
    199208                    <td>
    200209                        <?php $api_key = polizeipresse_get_option(POLIZEIPRESSE_API_KEY); ?>
     
    206215                for($office = 0; $office < POLIZEIPRESSE_MAX_OFFICE_COUNT; $office++) {
    207216?>
    208                     <tr valign="top">
    209                         <th scope="row">
    210                             <label for="office_name0"><?php _e('Police office', 'Polizeipresse'); ?></lable>
    211                         </th>
     217                    <tr valign="top" class="officeRow">
     218                        <td scope="row" class="label">
     219                            <label for="office_name<?php echo $office;?>"><?php _e('Police office', 'Polizeipresse'); ?></lable>
     220                        </td>
    212221                        <td>
    213222                            <input name="office_id<?php echo $office;?>"
     
    222231                                value="<?php echo polizeipresse_get_option(POLIZEIPRESSE_OFFICE_NAME . $office); ?>"
    223232                                type="text" class="regular-text" readonly="readonly" />
     233                        </td>
     234                        <td>
     235                            &nbsp;
     236                        </td>
     237                    </tr>
     238                    <tr>
     239                        <td>
     240                            &nbsp;
     241                        </td>
     242                        <td>
    224243                            <button id="searchOfficeDialogButton<?php echo $office;?>"
    225244                                class="searchOfficeDialogButton button-secondary" <?php echo (empty($api_key) ? ' disabled="disabled" ' : '') ?>>
     
    232251                        </td>
    233252                    </tr>
     253                    <tr>
     254                        <td scope="row">
     255                            <label for="office_category_id<?php echo $office;?>"><?php _e('Category for new posts', 'Polizeipresse'); ?></lable>
     256                        </td>
     257                        <td>
     258<?php
     259                            $current_cat = polizeipresse_get_option(POLIZEIPRESSE_OFFICE_CATEGORY_ID . $office);
     260                            wp_dropdown_categories("hide_empty=0&name=office_category_id" . $office . "&selected=" . $current_cat . "&show_option_none=Default");
     261?>
     262                        </td>
     263                    </tr>
    234264<?php
    235265                }
     
    250280
    251281                <tr valign="top">
    252                     <th scope="row">
     282                    <td scope="row" class="label">
    253283                        <label for="filter_positive"><?php _e('Positive filters', 'Polizeipresse'); ?>:<br/>
    254284                            (<?php _e('Separate multiple filters by comma.', 'Polizeipresse'); ?>)
    255285                        </lable>
    256                     </th>
     286                    </td>
    257287                    <td>
    258288                        <textarea name="filter_positive" cols="50" rows="5"><?php echo polizeipresse_get_option(POLIZEIPRESSE_FILTER_POSITIVE); ?></textarea>
     
    261291
    262292                <tr valign="top">
    263                     <th scope="row">
     293                    <td scope="row" class="label">
    264294                        <label for="filter_negative"><?php _e('Negative filters', 'Polizeipresse'); ?>:<br/>
    265295                            (<?php _e('Separate multiple filters by comma.', 'Polizeipresse'); ?>)
    266296                        </lable>
    267                     </th>
     297                    </td>
    268298                    <td>
    269299                        <textarea name="filter_negative" cols="50" rows="5"><?php echo polizeipresse_get_option(POLIZEIPRESSE_FILTER_NEGATIVE); ?></textarea>
     
    285315
    286316                <tr valign="top">
    287                     <th scope="row">
     317                    <td scope="row" class="label">
    288318                        <label for="cron"><?php _e('Enable cronjob', 'Polizeipresse'); ?>:</lable>
    289                     </th>
     319                    </td>
    290320                    <td>
    291321                        <input type="checkbox" name="cron_enabled" value="true" <?php echo (polizeipresse_is_cron_enabled()) ? 'checked' : ''; ?> >
     
    294324
    295325                <tr valign="top">
    296                     <th scope="row">
     326                    <td scope="row" class="label">
    297327                        <label for="cron_user_id"><?php _e('User for new posts', 'Polizeipresse'); ?>:</lable>
    298                     </th>
     328                    </td>
    299329                    <td>
    300330<?php
     
    306336
    307337                <tr valign="top">
    308                     <th scope="row">
    309                         <label for="cron_categorie_id"><?php _e('Category for new posts', 'Polizeipresse'); ?>:</lable>
    310                     </th>
    311                     <td>
    312 <?php
    313                         $current_cat = polizeipresse_get_option(POLIZEIPRESSE_CRON_ADD_CATEGORIE_ID);
    314                         wp_dropdown_categories("hide_empty=0&name=cron_categorie_id&selected=" . $current_cat . "&show_option_none=Keine");
    315 ?>
    316                     </td>
    317                 </tr>
    318 
    319                 <tr valign="top">
    320                     <th scope="row">
     338                    <td scope="row" class="label">
     339                        <label for="cron_categorie_id"><?php _e('Default category for new posts', 'Polizeipresse'); ?>:</lable>
     340                    </td>
     341                    <td>
     342<?php
     343                        $current_cat = polizeipresse_get_option(POLIZEIPRESSE_DEFAULT_CATEGORY_ID);
     344                        wp_dropdown_categories("hide_empty=0&name=default_category_id&selected=" . $current_cat . "&show_option_none=Keine");
     345?>
     346                    </td>
     347                </tr>
     348
     349                <tr valign="top">
     350                    <td scope="row" class="label">
    321351                        <label for="cron_add_publish"><?php _e('Publish new posts immediately', 'Polizeipresse'); ?>:</lable>
    322                     </th>
     352                    </td>
    323353                    <td>
    324354                        <input type="checkbox" name="cron_add_publish" value="true" <?php echo polizeipresse_get_option(POLIZEIPRESSE_CRON_ADD_PUBLISH) ? 'checked' : ''; ?> >
     
    327357
    328358                <tr valign="top">
    329                     <th scope="row">
     359                    <td scope="row" class="label">
    330360                        <label for="cron_notify"><?php _e('Notify on new stories', 'Polizeipresse'); ?>:</lable>
    331                     </th>
     361                    </td>
    332362                    <td>
    333363                        <input type="checkbox" name="cron_notify" value="true" <?php echo polizeipresse_get_option(POLIZEIPRESSE_CRON_NOTIFY) ? 'checked' : ''; ?> >
     
    339369?>
    340370                    <tr valign="top">
    341                         <th scope="row">
     371                        <td scope="row" class="label">
    342372                            <label for="cron_last_story_id<?php echo $office;?>">
    343373<?php
     
    349379                                echo "(" . $office_name . ")";
    350380?>:</lable>
    351                         </th>
     381                        </td>
    352382                        <td>
    353383                            <input name="cron_last_story_id<?php echo $office;?>" size="10"
     
    355385                                type="text"
    356386                                readonly="readonly" />
     387                        </td>
    357388                    </tr>
    358389<?php
     
    360391?>
    361392                    <tr valign="top">
    362                         <th scope="row">
     393                        <td scope="row" class="label">
    363394                            <label"><?php _e('Last cron execution time', 'Polizeipresse'); ?>:</lable>
    364                         </th>
     395                        </td>
    365396                        <td>
    366397<?php
  • polizeipresse/trunk/css/admin.css

    r511342 r791815  
    8080    font-weight: bold;
    8181}
     82
     83#PolizeipresseTabGeneral {
     84}
     85
     86#PolizeipresseTabGeneral .label {
     87    width: 30ex;
     88}
     89
     90#PolizeipresseTabGeneral .officeRow {
     91    border-top: 1px solid #000000;
     92}
     93
     94#PolizeipresseTabFilter {
     95}
     96
     97#PolizeipresseTabFilter .label {
     98    width: 40ex;
     99}
     100
     101#PolizeipresseTabCron {
     102}
     103
     104#PolizeipresseTabCron .label {
     105    width: 50ex;
     106}
  • polizeipresse/trunk/i18n/Polizeipresse-de_DE.po

    r788212 r791815  
    1515"X-Poedit-SearchPath-0: .\n"
    1616
    17 #: admin.php:14
     17
    1818msgid "Polizeipresse plugin: Please enter API key select police office"
    1919msgstr "Polizeipresse plugin: Bitte API-Schlüssel eingeben und Dienststellen auswählen."
    2020
    21 #: admin.php:105
     21
    2222msgid "Your settings have been saved."
    2323msgstr "Ihre Einstellungen wurden gespeichert."
    2424
    25 #: admin.php:114
     25
    2626msgid "Stories have been loaded."
    2727msgstr "Meldungen wurden geladen."
    2828
    29 #: admin.php:125
     29
    3030msgid "Last processed story id has been reset."
    3131msgstr "Zuletzt verarbeitete Meldungs-ID wurde zurückgesetzt."
    3232
    33 #: admin.php:144
     33
    3434msgid "Options"
    3535msgstr "Optionen"
    3636
    37 #: admin.php:149
     37
    3838msgid "General"
    3939msgstr "Allgemein"
    4040
    41 #: admin.php:150
     41
    4242msgid "Filter"
    4343msgstr "Filter"
    4444
    45 #: admin.php:151
     45
    4646msgid "Cronjob"
    4747msgstr "Cronjob"
    4848
    49 #: admin.php:160
     49
    5050msgid "This page contains fundamental plugin settings. Without API key and office id the plugin is unable to work."
    5151msgstr "Auf dieser Seite legen Sie grundlegende Einstellungen des Plugins fest. Ohne API-Schlüssel und ausgewählte Dienststelle funktioniert das Plugin nicht."
    5252
    53 #: admin.php:162
     53
    5454msgid "If you do not have an API key, please register on the following page to get one"
    5555msgstr "Wenn Sie noch keinen API-Schlüssel haben, können Sie diesen auf der folgenden Seite bekommen"
    5656
    57 #: admin.php:163
     57
    5858msgid "Click here"
    5959msgstr "Hier clicken"
    6060
    61 #: admin.php:170
     61
    6262msgid "Polizeipresse API key"
    6363msgstr "Polizeipresse API-Schlüssel"
    6464
    65 #: admin.php:180
     65
    6666msgid "Police office"
    6767msgstr "Polizeidienststelle"
    6868
    69 #: admin.php:188
    70 #: admin.php:337
     69
     70
    7171msgid "Search for offices"
    7272msgstr "Nach Polizeistationen suchen"
    7373
    74 #: admin.php:337
     74
    7575msgid "Remove office"
    7676msgstr "Polizeistationen löschen"
    7777
    78 #: admin.php:201
     78
    7979msgid "On this page you can define filters. These filteres are used to filter police stories. Multiple filters can be separated by comma."
    8080msgstr "Auf dieser Seite können Sie Filter definieren. Diese Filter werden verwendet, um Polizeimeldungen zu filtern. Mehrere Filter können durch Komma getrennt werden."
    8181
    82 #: admin.php:208
     82
    8383msgid "Positive filters"
    8484msgstr "Positive Filter"
    8585
    86 #: admin.php:209
    87 #: admin.php:220
     86
     87
    8888msgid "Separate multiple filters by comma."
    8989msgstr "Mehrere Filter durch Komma trennen"
    9090
    91 #: admin.php:219
     91
    9292msgid "Negative filters"
    9393msgstr "Negative Filter"
    9494
    95 #: admin.php:236
     95
    9696msgid "New police stories can be automatically loaded and added to your blog. This is done every hour."
    9797msgstr "Neue Polizeimeldungen können automatisch abgefragt und zu Ihrem Blog hinzugefügt werden. Die Abfrage geschieht stündlich."
    9898
    99 #: admin.php:243
     99
    100100msgid "Enable cronjob"
    101101msgstr "Cronjob einschalten"
    102102
    103 #: admin.php:252
     103
    104104msgid "User for new posts"
    105105msgstr "Benutzer für neue Artikel"
    106106
    107 #: admin.php:264
     107
    108108msgid "Category for new posts"
    109109msgstr "Kategorie für neue Artikel"
    110110
    111 #: admin.php:276
     111
     112msgid "Default category for new posts"
     113msgstr "Default-Kategorie für neue Artikel"
     114
     115
    112116msgid "Publish new posts immediately"
    113117msgstr "Neue Meldungen sofort veröffentlichen"
    114118
    115 #: admin.php:285
     119
    116120msgid "Notify on new stories"
    117121msgstr "Alarmierung bei neuen Meldungen"
    118122
    119 #: admin.php:294
     123
    120124msgid "Last processed story id"
    121125msgstr "Letzte verarbeitete Meldungs-ID"
     
    124128msgstr "Letzt Ausführung des Cronjobs"
    125129
    126 #: admin.php:303
    127 #: admin.php:311
     130
     131
    128132msgid "unknown"
    129133msgstr "unbekannt"
    130134
    131 #: admin.php:311
     135
    132136msgid "Date/time"
    133137msgstr "Datum/Uhrzeit"
    134138
    135 #: admin.php:311
     139
    136140msgid "State"
    137141msgstr "Status"
    138142
    139 #: admin.php:311
     143
    140144msgid "successfull"
    141145msgstr "erfolgreich"
    142146
    143 #: admin.php:318
     147
    144148msgid "Load stories now"
    145149msgstr "Jetzt neue Meldungen laden"
    146150
    147 #: admin.php:320
     151
    148152msgid "Reset last processed story id"
    149153msgstr "Zuletzt verarbeitete Meldungs-ID zurücksetzen"
    150154
    151 #: admin.php:329
     155
    152156msgid "Save all"
    153157msgstr "Alles speichern"
    154158
    155 #: admin.php:341
     159
    156160msgid "You can search for German police offices here. Start the search and select one item from the result list. Press apply to accept."
    157161msgstr "Sie können hier nach deutschen Polizeidienststellen suchen. Nach der Suche wählen sie eine Dienststelle aus und drücken 'übernehmen'."
    158162
    159 #: admin.php:346
     163
    160164msgid "Search terms"
    161165msgstr "Suche"
    162166
    163 #: admin.php:355
     167
    164168msgid "Search"
    165169msgstr "Suchen"
    166170
    167 #: admin.php:357
     171
    168172msgid "Cancel"
    169173msgstr "Abbrechen"
    170174
    171 #: admin.php:364
     175
    172176msgid "Search result"
    173177msgstr "Suchergebnis"
    174178
    175 #: admin.php:368
     179
    176180msgid "Apply"
    177181msgstr "Übernehmen"
    178182
    179 #: admin.php:410
     183
    180184msgid "No result from server."
    181185msgstr "Keine Dienststelle gefunden."
    182186
    183 #: admin.php:411
     187
    184188msgid "An error occurred"
    185189msgstr "Ein unbekannter Fehler ist aufgetreten."
    186190
    187 #: admin.php:412
     191
    188192msgid "Please enter API key"
    189193msgstr "Bitte API-Schlüssel eingeben"
    190194
    191 #: admin.php:413
     195
    192196msgid "Please select police office"
    193197msgstr "Bitte Dienststelle auswählen"
    194198
    195 #: Polizeipresse.php:294
     199
    196200msgid "Source"
    197201msgstr "Quelle"
    198202
    199 #: Polizeipresse.php:329
     203
    200204msgid "Polizeipresse: New post added"
    201205msgstr "Polizeipresse: Neuen Artikel hinzugefügt"
    202206
    203 #: Polizeipresse.php:330
     207
    204208msgid "URL to admin page"
    205209msgstr "URL zur Admin-Seite"
    206210
    207 #: widget.php:28
     211
    208212msgid "Displays latest police stories"
    209213msgstr "Zeigt aktuelle Polizeimeldungen"
    210214
    211 #: widget.php:85
     215
    212216msgid "No stories"
    213217msgstr "Keine Meldungen vorhanden"
    214218
    215 #: widget.php:112
     219
    216220msgid "Latest police stories"
    217221msgstr "Letzte Polizeimeldungen"
    218222
    219 #: widget.php:121
     223
    220224msgid "Title"
    221225msgstr "Titel"
    222226
    223 #: widget.php:128
     227
    224228msgid "Story count"
    225229msgstr "Anzahl Meldungen"
    226230
    227 #: widget.php:140
     231
    228232msgid "Show date"
    229233msgstr "Datum anzeigen"
    230234
    231 #: widget.php:147
     235
    232236msgid "Cache timeout"
    233237msgstr "Cache-Timeout"
    234238
    235 #: widget.php:149
     239
    236240msgid "minute"
    237241msgstr "Minute"
    238242
    239 #: widget.php:150
    240 #: widget.php:151
    241 #: widget.php:152
    242 #: widget.php:153
     243
     244
     245
     246
    243247msgid "minutes"
    244248msgstr "Minuten"
    245249
    246 #: widget.php:154
     250
    247251msgid "hour"
    248252msgstr "Stunde"
    249253
    250 #: widget.php:155
     254
    251255msgid "hours"
    252256msgstr "Stunden"
  • polizeipresse/trunk/options.php

    r788944 r791815  
    99define('POLIZEIPRESSE_OFFICE_ID',             'office_id');                // Old option. Needed for version 0.2 and below. Will be migrated.
    1010define('POLIZEIPRESSE_OFFICE_NAME',           'office_name');              // Old option. Needed for version 0.2 and below. Will be migrated.
     11define('POLIZEIPRESSE_CRON_ADD_CATEGORIE_ID', 'cron_add_categorie_id');    // Old option. Needed for version 0.2 and below. Will be migrated.
    1112
    1213for($office = 0; $office < POLIZEIPRESSE_MAX_OFFICE_COUNT; $office++) {
     
    1415    define('POLIZEIPRESSE_OFFICE_NAME' . $office,        'office_name' . $office);
    1516    define('POLIZEIPRESSE_CRON_LAST_STORY_ID' . $office, 'cron_last_story_id' . $office);
     17    define('POLIZEIPRESSE_OFFICE_CATEGORY_ID' . $office, 'office_category_id' . $office);
    1618}
    1719
     20define('POLIZEIPRESSE_DEFAULT_CATEGORY_ID',   'default_category_id');
    1821define('POLIZEIPRESSE_FILTER_POSITIVE',       'filter_positive');
    1922define('POLIZEIPRESSE_FILTER_NEGATIVE',       'filter_negative');
     
    2528define('POLIZEIPRESSE_CRON_NOTIFY',           'cron_add_notify');
    2629define('POLIZEIPRESSE_CRON_ADD_USER_ID',      'cron_add_user_id');
    27 define('POLIZEIPRESSE_CRON_ADD_CATEGORIE_ID', 'cron_add_categorie_id');
    2830
    2931
     
    3537    polizeipresse_update_option(POLIZEIPRESSE_OFFICE_ID,             '');  // Old option. Needed for version 0.2 and below. Will be migrated.
    3638    polizeipresse_update_option(POLIZEIPRESSE_OFFICE_NAME,           '');  // Old option. Needed for version 0.2 and below. Will be migrated.
     39    polizeipresse_update_option(POLIZEIPRESSE_DEFAULT_CATEGORY_ID,   '');
    3740    polizeipresse_update_option(POLIZEIPRESSE_FILTER_POSITIVE,       '');
    3841    polizeipresse_update_option(POLIZEIPRESSE_FILTER_NEGATIVE,       '');
     
    5053        polizeipresse_update_option(POLIZEIPRESSE_OFFICE_NAME . $office,        '');
    5154        polizeipresse_update_option(POLIZEIPRESSE_CRON_LAST_STORY_ID . $office, '');
     55        polizeipresse_update_option(POLIZEIPRESSE_OFFICE_CATEGORY_ID . $office,   '');
    5256    }
    5357}
Note: See TracChangeset for help on using the changeset viewer.