## Getting started In order to display a controls layout you need to define a simple Controls Layout Array (CLA) and to instance the WPDKUIControlsLayout class: $cla = array( 'Fieldset Legend Group' => array( 'Subtitle', // Optional subtitle array( array(...), array(...) ), // Row of items array(...), // New row array(...) // Items ); ); $layout = new WPDKUIControlsLayout( $cla ); $layout->display();
Author: =undo= (info@wpxtre.me)
Example #1
0
 /**
  * Display
  *
  * @brief Display
  */
 public function draw()
 {
     // Create a nonce key
     $nonce = md5($this->id);
     $input_hidden_nonce = new WPDKHTMLTagInput('', $nonce, $nonce);
     $input_hidden_nonce->type = WPDKHTMLTagInputType::HIDDEN;
     $input_hidden_nonce->value = wp_create_nonce($this->id);
     $input_hidden_class = new WPDKHTMLTagInput('', 'wpdk_preferences_class');
     $input_hidden_class->type = WPDKHTMLTagInputType::HIDDEN;
     $input_hidden_class->value = get_class($this->preferences);
     $input_hidden_branch = new WPDKHTMLTagInput('', 'wpdk_preferences_branch');
     $input_hidden_branch->type = WPDKHTMLTagInputType::HIDDEN;
     $input_hidden_branch->value = $this->branch_property;
     $layout = new WPDKUIControlsLayout($this->fields($this->branch));
     $form = new WPDKHTMLTagForm($input_hidden_nonce->html() . $input_hidden_class->html() . $input_hidden_branch->html() . $layout->html() . $this->buttonsUpdateReset());
     $form->name = 'wpdk_preferences_view_form-' . $this->branch_property;
     $form->id = $form->name;
     $form->class[] = 'wpdk-form wpdk-preferences-view-' . $this->branch_property;
     $form->method = 'post';
     $form->action = '';
     /**
      * Filter the form object for this branch view.
      *
      * @param WPDKHTMLTagForm $form An instance of WPDKHTMLTagForm class.
      */
     $form = apply_filters('wpdk_preferences_branch_form', $form);
     /**
      * Fires before display the view. You can add your custome feedback message.
      */
     do_action('wpdk_preferences_feedback-' . $this->branch_property);
     $form->display();
 }
Example #2
0
 /**
  * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen.
  *
  * The action only fires if the current user is editing their own profile.
  *
  * @since WP 2.0.0
  *
  * @param WP_User $profileuser The current WP_User object.
  */
 public function show_user_profile($profileuser)
 {
     echo '<br clear="all" /><a name="wpdk"></a>';
     $message = __('This view <strong>is enhanced</strong> by wpXtreme and WPDK framework. Please, have a look below for additional information.', WPDK_TEXTDOMAIN);
     $alert = new WPDKUIAlert('wpdk-alert-show_user_profile', $message, WPDKUIAlertType::INFORMATION);
     $alert->dismissPermanent = true;
     $alert->display();
     // Only the administrator can edit this extra information
     $disabled = !current_user_can('manage_options');
     // Sanitize values
     $last_time_success_login = $profileuser->get(WPDKUserMeta::LAST_TIME_SUCCESS_LOGIN);
     $last_time_wrong_login = $profileuser->get(WPDKUserMeta::LAST_TIME_WRONG_LOGIN);
     $last_time_logout = $profileuser->get(WPDKUserMeta::LAST_TIME_LOGOUT);
     $status_description = $profileuser->get(WPDKUserMeta::STATUS_DESCRIPTION);
     // Display WPDK user extends information
     $fields = array(__('Login information', WPDK_TEXTDOMAIN) => array(array(array('type' => WPDKUIControlType::DATETIME, 'name' => WPDKUserMeta::LAST_TIME_SUCCESS_LOGIN, 'label' => __('Last success login', WPDK_TEXTDOMAIN), 'value' => empty($last_time_success_login) ? '' : WPDKDateTime::format($last_time_success_login, WPDKDateTime::DATETIME_SECONDS_LESS_FORMAT_PHP), 'disabled' => $disabled), array('type' => WPDKUIControlType::NUMBER, 'name' => WPDKUserMeta::COUNT_SUCCESS_LOGIN, 'label' => __('# success login', WPDK_TEXTDOMAIN), 'value' => $profileuser->get(WPDKUserMeta::COUNT_SUCCESS_LOGIN), 'disabled' => true)), array(array('type' => WPDKUIControlType::DATETIME, 'name' => WPDKUserMeta::LAST_TIME_WRONG_LOGIN, 'label' => __('Last wrong login', WPDK_TEXTDOMAIN), 'value' => empty($last_time_wrong_login) ? '' : WPDKDateTime::format($last_time_wrong_login, WPDKDateTime::DATETIME_SECONDS_LESS_FORMAT_PHP), 'disabled' => $disabled), array('type' => WPDKUIControlType::NUMBER, 'name' => WPDKUserMeta::COUNT_WRONG_LOGIN, 'label' => __('# wrong login', WPDK_TEXTDOMAIN), 'value' => $profileuser->get(WPDKUserMeta::COUNT_WRONG_LOGIN), 'disabled' => $disabled))), __('Logout information', WPDK_TEXTDOMAIN) => array(array(array('type' => WPDKUIControlType::DATETIME, 'name' => WPDKUserMeta::LAST_TIME_LOGOUT, 'label' => __('Last logout', WPDK_TEXTDOMAIN), 'value' => empty($last_time_logout) ? '' : WPDKDateTime::format($last_time_logout, WPDKDateTime::DATETIME_SECONDS_LESS_FORMAT_PHP), 'disabled' => $disabled))), __('Status', WPDK_TEXTDOMAIN) => array(array(array('type' => WPDKUIControlType::SELECT, 'name' => WPDKUserMeta::STATUS, 'label' => __('Status', WPDK_TEXTDOMAIN), 'value' => $profileuser->get(WPDKUserMeta::STATUS), 'options' => WPDKUserStatus::statuses(), 'disabled' => $disabled)), array(array('type' => WPDKUIControlType::TEXTAREA, 'name' => WPDKUserMeta::STATUS_DESCRIPTION, 'rows' => 3, 'cols' => 40, 'label' => __('Description', WPDK_TEXTDOMAIN), 'placeholder' => __('eg: this user is disabled because...', WPDK_TEXTDOMAIN), 'value' => $status_description, 'disabled' => $disabled))));
     /**
      * Filter the layout control array with the extra WPDK fields.
      *
      * You can use this filter or `wpdk_users_show_user_profile` action to modify the default layout control array.
      *
      * @param array   $fields      Layout array fields.
      * @param WP_User $profileuser The current WP_User object.
      */
     $fields = apply_filters('wpdk_users_fields_profile', $fields, $profileuser);
     $layout = new WPDKUIControlsLayout($fields);
     /**
      * Fires after display the layout controls.
      *
      * You can use this action or `wpdk_users_fields_profile` filter to modify the default layout control array.
      *
      * @deprecated since 1.7.2 - Use `wpdk_user_profile_tabs` filter instead
      *
      * @param WP_User $profileuser The current WP_User object.
      */
     do_action('wpdk_users_show_user_profile', $profileuser);
     // Defaults
     $tabs = array();
     if (current_user_can('edit_users')) {
         // WPDK tabs
         $tabs = array(new WPDKjQueryTab('wpdk-user-profile', __('WPDK'), '<div id="wpdk-user-profile">' . $layout->html() . '</div>'));
     }
     /**
      * Filter the tabs list used to extends user profile edit.
      *
      * @since 1.7.2
      *
      * @param array   $tabs        The array tabs list.
      * @param WP_User $profileuser The current WP_User object.
      */
     $tabs = apply_filters('wpdk_user_profile_tabs', $tabs, $profileuser);
     $jquery_tabs = new WPDKjQueryTabsView('wpdk-users', $tabs, true);
     $jquery_tabs->display();
 }
Example #3
0
 /**
  * Display the content view with form, introduction, fields or custom content. You can override this method with your
  * own drawing.
  *
  * @brief Display the content view form
  *
  */
 public function draw()
 {
     /* Create a nonce key. */
     $nonce = md5($this->id);
     $input_hidden_nonce = new WPDKHTMLTagInput('', $nonce, $nonce);
     $input_hidden_nonce->type = WPDKHTMLTagInputType::HIDDEN;
     $input_hidden_nonce->value = wp_create_nonce($this->id);
     $layout = new WPDKUIControlsLayout($this->fields());
     $form = new WPDKHTMLTagForm($input_hidden_nonce->html() . $this->_introduction() . $layout->html() . $this->buttonsUpdateReset());
     $form->name = 'wpdk_configuration_view_form-' . $this->id;
     $form->id = $form->name;
     $form->class = 'wpdk-form wpdk-configuration-view-' . $this->id;
     $form->method = 'post';
     $form->action = '';
     $form->display();
 }
Example #4
0
    /**
     * Return the HTML markup for dynamic table
     *
     * @brief Get the HTML markup for dynamic table
     *
     * @return string
     */
    public function draw()
    {
        WPDKHTML::startCompress();
        ?>
    <table id="<?php 
        printf('wpdk-dynamic-table-%s', $this->id);
        ?>
"
           class="wpdk-dynamic-table <?php 
        echo $this->sortable ? 'wpdk-dynamic-table-sortable' : '';
        ?>
"
      <?php 
        echo $this->sortable ? 'data-sortable="true"' : '';
        ?>
           cellspacing="0"
           cellpadding="0"
           border="0">

        <!-- Columns -->
        <thead>
          <?php 
        $index = 0;
        foreach ($this->_columns() as $column_key => $column) {
            ?>
            <?php 
            if (self::COLUMN_ROW_MANAGE != $column_key) {
                ?>
              <th <?php 
                echo true == $this->sortable && empty($index) ? 'colspan="2"' : '';
                ?>
                class="wpdk-dynamic-table-column-<?php 
                echo $column_key;
                ?>
">
                <?php 
                echo $column['_label'];
                $index++;
                ?>
              </th>
            <?php 
            }
            ?>
          <?php 
        }
        ?>
        </thead>

        <tbody>

          <!-- This row is used for clone -->
          <tr class="wpdk-dt-clone">
            <?php 
        $index = 0;
        foreach ($this->_columns() as $column_key => $column) {
            ?>

              <?php 
            if (self::COLUMN_ROW_MANAGE == $column_key) {
                ?>
                <td class="<?php 
                echo $column_key;
                ?>
">
                  <?php 
                echo $this->buttonAdd();
                ?>
                  <span class="wpdk-dt-clone delete"><?php 
                echo $this->buttonDelete();
                ?>
</span>
                </td>
              <?php 
            } else {
                ?>
                <?php 
                if ($this->sortable && empty($index)) {
                    ?>
                  <td><?php 
                    WPDKGlyphIcons::display(WPDKGlyphIcons::MENU);
                    ?>
</td>
                <?php 
                }
                ?>
                <td class="wpdk-dynamic-table-cel-<?php 
                echo $column_key;
                ?>
">
                  <?php 
                echo WPDKUIControlsLayout::item($column);
                $index++;
                ?>
                </td>
              <?php 
            }
            ?>

            <?php 
        }
        ?>
          </tr>

          <!-- Main Body -->
          <?php 
        foreach ($this->items() as $item) {
            ?>
            <tr>
              <?php 
            $index = 0;
            foreach ($this->_columns() as $column_key => $column) {
                $column['value'] = isset($item[$column_key]) ? $item[$column_key] : '';
                ?>

                <?php 
                if (self::COLUMN_ROW_MANAGE == $column_key) {
                    ?>
                  <td class="<?php 
                    echo $column_key;
                    ?>
">
                    <?php 
                    echo $this->buttonDelete();
                    ?>
                  </td>
                <?php 
                } else {
                    ?>
                  <?php 
                    if ($this->sortable && empty($index)) {
                        ?>
                    <td><?php 
                        WPDKGlyphIcons::display(WPDKGlyphIcons::MENU);
                        ?>
</td>
                  <?php 
                    }
                    ?>
                  <td class="wpdk-dynamic-table-cel-<?php 
                    echo $column_key;
                    ?>
">
                    <?php 
                    echo WPDKUIControlsLayout::item($column);
                    $index++;
                    ?>
                  </td>
                <?php 
                }
                ?>

              <?php 
            }
            ?>
            </tr>
          <?php 
        }
        ?>

          <!-- Extra last child row -->
          <tr>
            <?php 
        $index = 0;
        foreach ($this->_columns() as $column_key => $column) {
            ?>

              <?php 
            if (self::COLUMN_ROW_MANAGE == $column_key) {
                ?>
                <td class="<?php 
                echo $column_key;
                ?>
">
                  <?php 
                echo $this->buttonAdd();
                ?>
                  <span class="wpdk-dt-clone delete"><?php 
                echo $this->buttonDelete();
                ?>
</span>
                </td>
              <?php 
            } else {
                ?>
                <?php 
                if ($this->sortable && empty($index)) {
                    ?>
                  <td><?php 
                    WPDKGlyphIcons::display(WPDKGlyphIcons::MENU);
                    ?>
</td>
                <?php 
                }
                ?>
                <td class="wpdk-dynamic-table-cel-<?php 
                echo $column_key;
                ?>
">
                  <?php 
                echo WPDKUIControlsLayout::item($column);
                $index++;
                ?>
                </td>
              <?php 
            }
            ?>

            <?php 
        }
        ?>
          </tr>

        </tbody>

        <?php 
        if (1 == 0) {
            ?>
        <!-- Footer -->
        <tfoot>
          <tr>
            <?php 
            $index = 0;
            foreach ($this->_columns() as $column_key => $column) {
                ?>

              <?php 
                if (self::COLUMN_ROW_MANAGE != $column_key) {
                    ?>
                <td <?php 
                    echo true == $this->sortable && empty($index) ? 'colspan="2"' : '';
                    ?>
                  class="wpdk-dynamic-table-cel-<?php 
                    echo $column_key;
                    ?>
"></td>
              <?php 
                }
                $index++;
                ?>

            <?php 
            }
            ?>
          </tr>
        </tfoot>
        <?php 
        }
        ?>

      </table>
  <?php 
        echo WPDKHTML::endHTMLCompress();
    }