Beispiel #1
0
            }
            // internal group test
            // list the fields for editing
            foreach ($attribute_columns[$group] as $attribute_column) {
                $edit_field_type = PDb_get_edit_field_type($attribute_column);
                if ('internal' == $group && in_array($attribute_column, array('order'))) {
                    continue;
                }
                // preserve backslashes in regex expressions
                if ($attribute_column == 'validation') {
                    $database_row[$attribute_column] = str_replace('\\', '\', $database_row[$attribute_column]);
                    if ($database_row['name'] == 'email' && $database_row[$attribute_column] == 'email') {
                        $database_row[$attribute_column] = 'email-regex';
                    }
                }
                $value = Participants_Db::prepare_value($database_row[$attribute_column]);
                $element_atts = array_merge($edit_field_type, array('name' => 'row_' . $database_row['id'] . '[' . $attribute_column . ']', 'value' => PDb_prep_value($value, (bool) ($attribute_column == 'validation'))));
                ?>
                      <td class="<?php 
                echo $attribute_column;
                ?>
"><?php 
                PDb_FormElement::print_element($element_atts);
                ?>
</td>
                      <?php 
            }
            // columns
            ?>
                  </tr>
                  <?php 
    /**
     * prints an individual group tab content
     * 
     * @param string $group current group name
     */
    protected function print_group_tab_content($group)
    {
        $internal_group = $group === 'internal';
        $hscroll = Participants_Db::plugin_setting_is_true('admin_horiz_scroll');
        ?>
      <div id="<?php 
        echo $group;
        ?>
" class="manage-fields-wrap" >
        <form id="manage_<?php 
        echo $group;
        ?>
_fields" method="post" autocomplete="off">
          <h3><?php 
        echo $this->group_titles[$group], ' ', $this->i18n['fields'];
        ?>
</h3>
          <p>
            <?php 
        if (!$internal_group) {
            // "add field" functionality
            PDb_FormElement::print_element(array('type' => 'submit', 'value' => $this->i18n['add field'], 'name' => 'action', 'attributes' => array('class' => 'button button-default', 'disabled' => 'disabled')));
            PDb_FormElement::print_element(array('type' => 'text', 'name' => 'title', 'value' => '', 'attributes' => array('placeholder' => $this->i18n['new field title'] . '&hellip;', 'class' => 'add_field')));
        }
        // skip internal groups
        // number of rows in the group
        $num_group_rows = count($this->fields_data[$group]);
        $last_order = $num_group_rows > 1 ? $this->fields_data[$group][$num_group_rows - 1]['order'] + 1 : 1;
        PDb_FormElement::print_hidden_fields(array('group' => $group, 'order' => $last_order));
        ?>
          </p>
          <?php 
        if ($hscroll) {
            ?>
          <div class="pdb-horiz-scroll-scroller">
          <div class="pdb-horiz-scroll-width">
            <?php 
        }
        ?>
            <table class="wp-list-table widefat fixed manage-fields" >
            <thead>
              <tr>
                <?php 
        if (!$internal_group) {
            ?>
                  <th scope="col" class="delete vertical-title"><span><?php 
            echo $this->table_header('delete');
            ?>
</span></th>
                  <?php 
        }
        // internal group test
        foreach ($this->attribute_columns[$group] as $attribute_column) {
            if ($internal_group && in_array($attribute_column, array('order'))) {
                continue;
            }
            $column_class = $attribute_column;
            $column_class .= in_array($attribute_column, array('order', 'persistent', 'sortable', 'admin_column', 'display_column', 'CSV', 'signup', 'display', 'readonly')) ? ' vertical-title' : '';
            $column_class .= in_array($attribute_column, array('admin_column', 'display_column')) ? ' number-column' : '';
            ?>
                  <th scope="col" class="<?php 
            echo $column_class;
            ?>
"><span><?php 
            echo $this->table_header($attribute_column);
            ?>
</span></th>
                <?php 
        }
        ?>
              </tr>
            </thead>
            <tbody id="<?php 
        echo $group;
        ?>
_fields">
              <?php 
        if ($num_group_rows < 1) {
            // there are no rows in this group to show
            ?>
                <tr><td colspan="<?php 
            echo count($this->attribute_columns[$group]) + 1;
            ?>
"><?php 
            _e('No fields in this group', 'participants-database');
            ?>
</td></tr>
                    <?php 
        } else {
            // add the rows of the group
            foreach ($this->fields_data[$group] as $database_row) {
                ?>
                  <tr id="db_row_<?php 
                echo $database_row['id'];
                ?>
">
                      <?php 
                if (!$internal_group) {
                    ?>
                      <td>
                        <?php 
                }
                // hidden field test
                // add the hidden fields
                foreach (array('id') as $attribute_column) {
                    $value = Participants_Db::prepare_value($database_row[$attribute_column]);
                    $element_atts = array_merge($this->get_edit_field_type($attribute_column), array('name' => 'row_' . $database_row['id'] . '[' . $attribute_column . ']', 'value' => $value));
                    PDb_FormElement::print_element($element_atts);
                }
                PDb_FormElement::print_element(array('type' => 'hidden', 'value' => '', 'name' => 'row_' . $database_row['id'] . '[status]', 'attributes' => array('id' => 'status_' . $database_row['id'])));
                if (!$internal_group) {
                    ?>
                          <a href="javascript:return false" title="<?php 
                    echo $database_row['id'];
                    ?>
" data-thing-name="delete_<?php 
                    echo $database_row['id'];
                    ?>
" class="delete" data-thing="<?php 
                    _e('field', 'participants-database');
                    ?>
"><span class="glyphicon glyphicon-remove"></span></a>
                      </td>
                      <?php 
                }
                // internal group test
                // list the fields for editing
                foreach ($this->attribute_columns[$group] as $attribute_column) {
                    $edit_field_type = $this->get_edit_field_type($attribute_column);
                    if ($internal_group && in_array($attribute_column, array('order'))) {
                        continue;
                    }
                    // preserve backslashes in regex expressions
                    if ($attribute_column == 'validation') {
                        if ($database_row['name'] == 'email' && $database_row[$attribute_column] == 'email') {
                            $database_row[$attribute_column] = 'email-regex';
                        }
                    }
                    $value = Participants_Db::prepare_value($database_row[$attribute_column]);
                    $element_atts = array_merge($edit_field_type, array('name' => 'row_' . $database_row['id'] . '[' . $attribute_column . ']', 'value' => $this->prep_value($value, in_array($attribute_column, array('title', 'description')))));
                    ?>
                      <td class="<?php 
                    echo $attribute_column;
                    ?>
"><?php 
                    PDb_FormElement::print_element($element_atts);
                    ?>
</td>
                    <?php 
                }
                // columns
                ?>
                  </tr>
                <?php 
            }
            // rows
        }
        // num group rows
        ?>
            </tbody>
          </table>
            <?php 
        if ($hscroll) {
            ?>
          </div>
          </div>
          <?php 
        }
        ?>
          <p class="submit">
            <?php 
        PDb_FormElement::print_element(array('type' => 'submit', 'name' => 'action', 'value' => $this->i18n['update fields'], 'class' => 'button button-primary manage-fields-update'));
        ?>
          </p>
        </form>
      </div><!-- tab content container -->
  <?php 
    }