Plugin Directory

Changeset 1911614


Ignore:
Timestamp:
07/19/2018 12:39:20 PM (8 years ago)
Author:
sdwebdevelopment
Message:
  • added tag directories
  • optimize display of classes
  • add class note
Location:
sd-classes
Files:
40 added
4 edited
24 copied

Legend:

Unmodified
Added
Removed
  • sd-classes/tags/1.1.0/readme.txt

    r1881839 r1911614  
    44Requires at least: 4.9.5
    55Tested up to: 4.9.5
    6 Stable tag: 1.0.0
     6Stable tag: 1.1.0
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    6060== Changelog ==
    6161
     62= 1.1.0 =
     63* Optimierungen in der Darstellung
     64* Kursnotiz hinzugefügt
     65* Screenshots hinzugefügt
     66
    6267= 1.0.0 =
    6368* erste stabile Version
  • sd-classes/tags/1.1.0/sdrost-classes.php

    r1881839 r1911614  
    2626Plugin Name: SDrost Classes
    2727Description: Ein Plugin um Kurse und deren Zeiten zu verwalten und anzuzeigen.
    28 Version: 1.0.0
     28Version: 1.1.0
    2929Author: Stefanie Drost
    3030Author URI: stefaniedrost.com
  • sd-classes/tags/1.1.0/src/SdrostClassesOptionPage.php

    r1881839 r1911614  
    99
    1010    const SDROST_DEFAULT_COLOR = '#960f1e';
     11    const SDROST_DEFAULT_SHORT_WEEKDAY = 1;
     12    const SDROST_DEFAULT_SHOW_WEEKEND = 1;
    1113
    1214    public function registerSdrostClassesSettings()
    1315    {
    1416        add_option( 'sdrost_classes_shortcode_color', self::SDROST_DEFAULT_COLOR);
     17        add_option( 'sdrost_classes_shortcode_short_weekday', self::SDROST_DEFAULT_SHORT_WEEKDAY);
     18        add_option( 'sdrost_classes_shortcode_show_weekend', self::SDROST_DEFAULT_SHOW_WEEKEND);
     19
    1520        register_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_color', 'sdrost_classes_callback' );
     21        register_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_short_weekday', 'sdrost_classes_callback' );
     22        register_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_show_weekend', 'sdrost_classes_callback' );
    1623    }
    1724
     
    4148                        </td>
    4249                    </tr>
     50                    <tr>
     51                        <th scope="row">
     52                            <label for="sdrost_classes_shortcode_short_weekday">Wochentage abkürzen</label>
     53                        </th>
     54                        <td>
     55                            <input type="checkbox" id="sdrost_classes_shortcode_short_weekday" name="sdrost_classes_shortcode_short_weekday"
     56                                   value="1" <?php if (get_option( 'sdrost_classes_shortcode_short_weekday' ) ) echo 'checked'  ?> />
     57                        </td>
     58                    </tr>
     59                    <tr>
     60                        <th scope="row">
     61                            <label for="sdrost_classes_shortcode_short_weekday">Wochenende anzeigen</label>
     62                        </th>
     63                        <td>
     64                            <input type="checkbox" id="sdrost_classes_shortcode_show_weekend" name="sdrost_classes_shortcode_show_weekend"
     65                                   value="1" <?php if (get_option( 'sdrost_classes_shortcode_show_weekend' ) ) echo 'checked'  ?> />
     66                        </td>
     67                    </tr>
    4368                    </tbody>
    4469                </table>
     
    5378    {
    5479        delete_option( 'sdrost_classes_shortcode_color' );
     80        delete_option( 'sdrost_classes_shortcode_short_weekday' );
     81        delete_option( 'sdrost_classes_shortcode_show_weekend' );
    5582        unregister_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_color', 'sdrost_classes_callback' );
     83        unregister_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_short_weekday', 'sdrost_classes_callback' );
     84        unregister_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_show_weekend', 'sdrost_classes_callback' );
    5685    }
    5786
  • sd-classes/tags/1.1.0/src/SdrostClassesShortCode.php

    r1881839 r1911614  
    1515        extract(shortcode_atts(array( 'class' => 1), $attributes));
    1616
     17        $shortWeekDayOption = esc_attr( get_option( 'sdrost_classes_shortcode_short_weekday') );
     18        $showWeekendOption = esc_attr( get_option( 'sdrost_classes_shortcode_show_weekend') );
     19        $maxDays = 7;
     20
    1721        $classesDataArray = SdrostClassPostType::getClassesByClassType($class);
     22        if (!boolval($showWeekendOption)) {
     23            $maxDays = 5;
     24        }
     25
    1826        $shortDayTable = [
    1927            0 => 'Mo',
     
    2836        $markup = '';
    2937        $markup .= SdrostClassRenderer::getStyleHtml(get_option( 'sdrost_classes_shortcode_color'));
    30         for ($i = 0; $i < 7; $i++) {
     38        for ($i = 0; $i < $maxDays; $i++) {
    3139            if (!isset($classesDataArray[$i])) {
    32                 $markup .= SdrostClassRenderer::getEmptyClassWeekdayTableHtml($shortDayTable[$i]);
     40                $day = $this->getDayByIndex($i, $shortWeekDayOption);
     41                $markup .= SdrostClassRenderer::getEmptyClassWeekdayTableHtml($day);
    3342            }
    3443            else {
    35                 $markup .= '<div class="classesWeekDay">' . $classesDataArray[$i][0]['day'] . '</div><br/>';
     44                $markup .= '<div class="classesWeekDay">' . $this->getDayByData($classesDataArray[$i][0], $shortWeekDayOption) . '</div><br/>';
    3645                foreach ($classesDataArray[$i] as $data) {
    3746                    $classObject = new SdrostClass();
    38                     $classObject->setDay($data['day'])
     47                    $day = $this->getDayByData($data, $shortWeekDayOption);
     48
     49                    $classObject->setDay($day)
    3950                        ->setBegin($data['begin'])
    4051                        ->setEnd($data['end'])
     52                        ->setNote($data['note'])
    4153                        ->setPlace($data['place'])
    4254                        ->setAddress($data['address'])
     
    5062        return $markup;
    5163    }
     64
     65
     66    private function getDayByIndex($dayIndex, $shortWeekDayOption)
     67    {
     68        $longDayTable = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonnabend'];
     69        $shortDayTable = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
     70
     71        if ($shortWeekDayOption) {
     72            return $shortDayTable[$dayIndex];
     73        }
     74
     75        return $longDayTable[$dayIndex];
     76    }
     77
     78
     79    private function getDayByData($data, $shortWeekDayOption)
     80    {
     81        if ($shortWeekDayOption) {
     82            return substr($data['day'], 0, 2);
     83        }
     84
     85        return $data['day'];
     86    }
    5287}
  • sd-classes/tags/1.1.0/src/entity/SdrostClass.php

    r1881839 r1911614  
    1717    private $day;
    1818    private $address;
     19    private $note;
    1920
    2021    /**
     
    153154        return $this->address;
    154155    }
     156
     157
     158    /**
     159     * @return string
     160     */
     161    public function getNote(): string
     162    {
     163        return $this->note;
     164    }
     165
     166
     167    /**
     168     * @param string $note
     169     * @return $this
     170     */
     171    public function setNote($note): SdrostClass
     172    {
     173        $this->note = $note;
     174
     175        return $this;
     176    }
    155177}
  • sd-classes/tags/1.1.0/src/helper/SdrostClassRenderer.php

    r1881839 r1911614  
    1616        $begin = $class->getBegin();
    1717        $end = $class->getEnd();
     18        $classNote = ($class->getNote()) ? $class->getNote() .'<br/><br/>' : '';
    1819        $place = $class->getPlace();
    1920        $trainer = $class->getTrainer();
     
    3132        </tr>
    3233        <tr>
    33             <td><strong>Trainerin</strong><br/>
    34                 $trainer</td>
     34            <td>
     35            $classNote
     36            <strong>Trainerin</strong><br/>
     37                $trainer
     38            </td>
    3539            <td>$address<br/><br/>
    36                 $googleLink
     40                $googleLink<br/><br/>
    3741            </td>
    3842        </tr>
     
    4650     * @return string
    4751     */
    48     public static function getEmptyClassWeekdayTableHtml($dayShortCode): string
     52    public static function getEmptyClassWeekdayTableHtml($day): string
    4953    {
    5054        return <<<EOT
    51 <div class="classesWeekDay">$dayShortCode</div>
     55<div class="classesWeekDay">$day</div>
    5256    <div class="classes-table-empty">
    5357        <br class="none"><strong>-</strong><br class="none"><br class="none">
  • sd-classes/tags/1.1.0/src/postType/SdrostClassBasePostType.php

    r1881839 r1911614  
    111111            $prio = get_post_meta($classData->ID, 'sdrost_class_weekday_priority_data', true);
    112112            $addressObject = get_post(get_post_meta($classData->ID, 'sdrost_class_address_data', true));
    113             $address = get_post_meta($addressObject->ID, 'sdrost_class_address_street_data', true) . '<br/>' . get_post_meta($addressObject->ID, 'sdrost_class_address_zipcode_data', true) . '' .
    114                 get_post_meta($addressObject->ID, 'sdrost_class_address_city_data', true) . '<br/>' . get_post_meta($addressObject->ID, 'sdrost_class_address_additional_data', true);
     113            $address = get_post_meta($addressObject->ID, 'sdrost_class_address_street_data', true) . '<br/>' .
     114                get_post_meta($addressObject->ID, 'sdrost_class_address_zipcode_data', true) . ' ' .
     115                get_post_meta($addressObject->ID, 'sdrost_class_address_city_data', true) . '<br/>' .
     116                get_post_meta($addressObject->ID, 'sdrost_class_address_additional_data', true);
    115117
    116118            $dataArray[(int)$prio][] = [
    117                 'day' => substr(get_post_meta($classData->ID, 'sdrost_class_day_data', true), 0, 2),
     119                'day' => get_post_meta($classData->ID, 'sdrost_class_day_data', true),
    118120                'begin' => get_post_meta($classData->ID, 'sdrost_class_begin_data', true),
    119121                'end' => get_post_meta($classData->ID, 'sdrost_class_end_data', true),
     122                'note' => get_post_meta($classData->ID, 'sdrost_class_note_data', true),
    120123                'place' => get_post_meta($addressObject->ID, 'sdrost_class_address_district_data', true),
    121124                'address' => $address,
  • sd-classes/tags/1.1.0/src/postType/SdrostClassPostType.php

    r1881839 r1911614  
    1111    const CLASS_END_COLUMN_KEY = 'sdrost_class_end';
    1212    const CLASS_DAY_COLUMN_KEY = 'sdrost_class_day';
     13    const CLASS_NOTE_COLUMN_KEY = 'sdrost_class_note';
    1314    const CLASS_TRAINER_COLUMN_KEY = 'sdrost_class_trainer';
    1415    const CLASS_ADDRESS_COLUMN_KEY = 'sdrost_class_address';
     
    6970        $columns[self::CLASS_DAY_COLUMN_KEY] = 'Tag';
    7071        $columns[self::CLASS_TRAINER_COLUMN_KEY] = 'Trainer';
    71         $columns[self::CLASS_ADDRESS_COLUMN_KEY] = 'Addresse';
    7272        $columns[self::CLASS_CLASS_COLUMN_KEY] = 'Kurs';
    7373        $columns['date'] = $date;
     
    7979    public function addSdrostClassesBox()
    8080    {
    81         add_meta_box( 'sdrostClasses_box','Kurs Daten',array(SdrostClassPostType::class, 'createSdrostClassDataBox' ), self::SDROST_CLASSES_POST_TYPE,'normal','high' );
     81        add_meta_box( 'sdrostClasses_box','Kurs Daten',array(SdrostClassPostType::class, 'createSdrostClassDataBox' ),
     82            self::SDROST_CLASSES_POST_TYPE,'normal','high' );
    8283        remove_meta_box( 'wp-editor', self::SDROST_CLASSES_POST_TYPE, 'normal' );
    8384    }
     
    104105            self::CLASS_BEGIN_COLUMN_KEY,
    105106            self::CLASS_END_COLUMN_KEY,
     107            self::CLASS_NOTE_COLUMN_KEY,
    106108            self::CLASS_ADDRESS_COLUMN_KEY,
    107109            self::CLASS_TRAINER_COLUMN_KEY,
     
    113115        $begin = get_post_meta( $post->ID, 'sdrost_class_begin_data', true );
    114116        $end = get_post_meta( $post->ID, 'sdrost_class_end_data', true );
     117        $note = get_post_meta( $post->ID, self::CLASS_NOTE_COLUMN_KEY . '_data', true );
    115118        $address = get_post_meta( $post->ID, self::CLASS_ADDRESS_COLUMN_KEY . '_data', true );
    116119        $trainer = get_post_meta( $post->ID, self::CLASS_TRAINER_COLUMN_KEY . '_data', true );
     
    148151            </div><br/>
    149152
     153            <label for="sdrost_class_note">Kursnotiz:</label><br/>
     154            <input type='text' id='sdrost_class_note_data' value="<?php echo $note; ?>" name='sdrost_class_note_data'><br/><br/>
     155
    150156            <label for="sdrost_class_address_data">Addresse:</label><br/>
    151157            <select name="sdrost_class_address_data" id='sdrost_class_address_data'>
     
    189195            self::CLASS_BEGIN_COLUMN_KEY,
    190196            self::CLASS_END_COLUMN_KEY,
     197            self::CLASS_NOTE_COLUMN_KEY,
    191198            self::CLASS_DAY_COLUMN_KEY,
    192199            self::CLASS_ADDRESS_COLUMN_KEY,
     
    206213            self::CLASS_BEGIN_COLUMN_KEY . '_data',
    207214            self::CLASS_END_COLUMN_KEY . '_data',
     215            self::CLASS_NOTE_COLUMN_KEY . '_data',
    208216            self::CLASS_DAY_COLUMN_KEY . '_data',
    209217            self::CLASS_ADDRESS_COLUMN_KEY . '_data',
  • sd-classes/trunk/src/SdrostClassesOptionPage.php

    r1881839 r1911614  
    99
    1010    const SDROST_DEFAULT_COLOR = '#960f1e';
     11    const SDROST_DEFAULT_SHORT_WEEKDAY = 1;
     12    const SDROST_DEFAULT_SHOW_WEEKEND = 1;
    1113
    1214    public function registerSdrostClassesSettings()
    1315    {
    1416        add_option( 'sdrost_classes_shortcode_color', self::SDROST_DEFAULT_COLOR);
     17        add_option( 'sdrost_classes_shortcode_short_weekday', self::SDROST_DEFAULT_SHORT_WEEKDAY);
     18        add_option( 'sdrost_classes_shortcode_show_weekend', self::SDROST_DEFAULT_SHOW_WEEKEND);
     19
    1520        register_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_color', 'sdrost_classes_callback' );
     21        register_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_short_weekday', 'sdrost_classes_callback' );
     22        register_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_show_weekend', 'sdrost_classes_callback' );
    1623    }
    1724
     
    4148                        </td>
    4249                    </tr>
     50                    <tr>
     51                        <th scope="row">
     52                            <label for="sdrost_classes_shortcode_short_weekday">Wochentage abkürzen</label>
     53                        </th>
     54                        <td>
     55                            <input type="checkbox" id="sdrost_classes_shortcode_short_weekday" name="sdrost_classes_shortcode_short_weekday"
     56                                   value="1" <?php if (get_option( 'sdrost_classes_shortcode_short_weekday' ) ) echo 'checked'  ?> />
     57                        </td>
     58                    </tr>
     59                    <tr>
     60                        <th scope="row">
     61                            <label for="sdrost_classes_shortcode_short_weekday">Wochenende anzeigen</label>
     62                        </th>
     63                        <td>
     64                            <input type="checkbox" id="sdrost_classes_shortcode_show_weekend" name="sdrost_classes_shortcode_show_weekend"
     65                                   value="1" <?php if (get_option( 'sdrost_classes_shortcode_show_weekend' ) ) echo 'checked'  ?> />
     66                        </td>
     67                    </tr>
    4368                    </tbody>
    4469                </table>
     
    5378    {
    5479        delete_option( 'sdrost_classes_shortcode_color' );
     80        delete_option( 'sdrost_classes_shortcode_short_weekday' );
     81        delete_option( 'sdrost_classes_shortcode_show_weekend' );
    5582        unregister_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_color', 'sdrost_classes_callback' );
     83        unregister_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_short_weekday', 'sdrost_classes_callback' );
     84        unregister_setting( 'sdrost_classes_options_group', 'sdrost_classes_shortcode_show_weekend', 'sdrost_classes_callback' );
    5685    }
    5786
  • sd-classes/trunk/src/SdrostClassesShortCode.php

    r1881839 r1911614  
    1515        extract(shortcode_atts(array( 'class' => 1), $attributes));
    1616
     17        $shortWeekDayOption = esc_attr( get_option( 'sdrost_classes_shortcode_short_weekday') );
     18        $showWeekendOption = esc_attr( get_option( 'sdrost_classes_shortcode_show_weekend') );
     19        $maxDays = 7;
     20
    1721        $classesDataArray = SdrostClassPostType::getClassesByClassType($class);
     22        if (!boolval($showWeekendOption)) {
     23            $maxDays = 5;
     24        }
     25
    1826        $shortDayTable = [
    1927            0 => 'Mo',
     
    2836        $markup = '';
    2937        $markup .= SdrostClassRenderer::getStyleHtml(get_option( 'sdrost_classes_shortcode_color'));
    30         for ($i = 0; $i < 7; $i++) {
     38        for ($i = 0; $i < $maxDays; $i++) {
    3139            if (!isset($classesDataArray[$i])) {
    32                 $markup .= SdrostClassRenderer::getEmptyClassWeekdayTableHtml($shortDayTable[$i]);
     40                $day = $this->getDayByIndex($i, $shortWeekDayOption);
     41                $markup .= SdrostClassRenderer::getEmptyClassWeekdayTableHtml($day);
    3342            }
    3443            else {
    35                 $markup .= '<div class="classesWeekDay">' . $classesDataArray[$i][0]['day'] . '</div><br/>';
     44                $markup .= '<div class="classesWeekDay">' . $this->getDayByData($classesDataArray[$i][0], $shortWeekDayOption) . '</div><br/>';
    3645                foreach ($classesDataArray[$i] as $data) {
    3746                    $classObject = new SdrostClass();
    38                     $classObject->setDay($data['day'])
     47                    $day = $this->getDayByData($data, $shortWeekDayOption);
     48
     49                    $classObject->setDay($day)
    3950                        ->setBegin($data['begin'])
    4051                        ->setEnd($data['end'])
     52                        ->setNote($data['note'])
    4153                        ->setPlace($data['place'])
    4254                        ->setAddress($data['address'])
     
    5062        return $markup;
    5163    }
     64
     65
     66    private function getDayByIndex($dayIndex, $shortWeekDayOption)
     67    {
     68        $longDayTable = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonnabend'];
     69        $shortDayTable = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
     70
     71        if ($shortWeekDayOption) {
     72            return $shortDayTable[$dayIndex];
     73        }
     74
     75        return $longDayTable[$dayIndex];
     76    }
     77
     78
     79    private function getDayByData($data, $shortWeekDayOption)
     80    {
     81        if ($shortWeekDayOption) {
     82            return substr($data['day'], 0, 2);
     83        }
     84
     85        return $data['day'];
     86    }
    5287}
  • sd-classes/trunk/src/helper/SdrostClassRenderer.php

    r1881839 r1911614  
    1616        $begin = $class->getBegin();
    1717        $end = $class->getEnd();
     18        $classNote = ($class->getNote()) ? $class->getNote() .'<br/><br/>' : '';
    1819        $place = $class->getPlace();
    1920        $trainer = $class->getTrainer();
     
    3132        </tr>
    3233        <tr>
    33             <td><strong>Trainerin</strong><br/>
    34                 $trainer</td>
     34            <td>
     35            $classNote
     36            <strong>Trainerin</strong><br/>
     37                $trainer
     38            </td>
    3539            <td>$address<br/><br/>
    36                 $googleLink
     40                $googleLink<br/><br/>
    3741            </td>
    3842        </tr>
     
    4650     * @return string
    4751     */
    48     public static function getEmptyClassWeekdayTableHtml($dayShortCode): string
     52    public static function getEmptyClassWeekdayTableHtml($day): string
    4953    {
    5054        return <<<EOT
    51 <div class="classesWeekDay">$dayShortCode</div>
     55<div class="classesWeekDay">$day</div>
    5256    <div class="classes-table-empty">
    5357        <br class="none"><strong>-</strong><br class="none"><br class="none">
  • sd-classes/trunk/src/postType/SdrostClassBasePostType.php

    r1881839 r1911614  
    111111            $prio = get_post_meta($classData->ID, 'sdrost_class_weekday_priority_data', true);
    112112            $addressObject = get_post(get_post_meta($classData->ID, 'sdrost_class_address_data', true));
    113             $address = get_post_meta($addressObject->ID, 'sdrost_class_address_street_data', true) . '<br/>' . get_post_meta($addressObject->ID, 'sdrost_class_address_zipcode_data', true) . '' .
    114                 get_post_meta($addressObject->ID, 'sdrost_class_address_city_data', true) . '<br/>' . get_post_meta($addressObject->ID, 'sdrost_class_address_additional_data', true);
     113            $address = get_post_meta($addressObject->ID, 'sdrost_class_address_street_data', true) . '<br/>' .
     114                get_post_meta($addressObject->ID, 'sdrost_class_address_zipcode_data', true) . ' ' .
     115                get_post_meta($addressObject->ID, 'sdrost_class_address_city_data', true) . '<br/>' .
     116                get_post_meta($addressObject->ID, 'sdrost_class_address_additional_data', true);
    115117
    116118            $dataArray[(int)$prio][] = [
    117                 'day' => substr(get_post_meta($classData->ID, 'sdrost_class_day_data', true), 0, 2),
     119                'day' => get_post_meta($classData->ID, 'sdrost_class_day_data', true),
    118120                'begin' => get_post_meta($classData->ID, 'sdrost_class_begin_data', true),
    119121                'end' => get_post_meta($classData->ID, 'sdrost_class_end_data', true),
     122                'note' => get_post_meta($classData->ID, 'sdrost_class_note_data', true),
    120123                'place' => get_post_meta($addressObject->ID, 'sdrost_class_address_district_data', true),
    121124                'address' => $address,
Note: See TracChangeset for help on using the changeset viewer.