/** * Return a key pairs array with the list of icons for statuses * * @brief Icons glyph * * @return array */ public static function icon_statuses() { $statuses = array(self::DRAFT => WPDKGlyphIcons::html(WPDKGlyphIcons::CLOCK), self::PUBLISH => WPDKGlyphIcons::html(WPDKGlyphIcons::OK), self::TRASH => WPDKGlyphIcons::html(WPDKGlyphIcons::TRASH)); return $statuses; }
/** * Display the HTML markup content for this view. * * @return string */ public function display() { /** * Filter the list of registered placeholder. * * @param array $placeholders An array key value pairs with the list of registered placeholders. */ $placeholders = apply_filters('wpdk_post_placeholders', array()); // Reverse :) $placeholders = array_reverse($placeholders, true); // This is impossible if (empty($placeholders)) { _e('No PLaceholders registered/found'); } // Owner array $owners = array(); // Build the owner select combo foreach ($placeholders as $placeholder_key => $info) { $key = sanitize_title($info[1]); $owners[$key] = $info[1]; } ?> <select id="wpdk-post-placeholder-select" class="wpdk-ui-control wpdk-form-select"> <option selected="selected" style="display:none" disabled="disabled"><?php _e('Filter by Owner'); ?> </option> <option value=""><?php _e('All'); ?> </option> <?php foreach ($owners as $key => $owner) { ?> <option value="<?php echo $key; ?> "><?php echo $owner; ?> </option> <?php } ?> </select> <div class="wpdk-post-placeholders"><?php // Group by owner $owner = ''; // Loop into the placeholders foreach ($placeholders as $placeholder_key => $info) { ?> <?php echo $owner != $info[1] ? sprintf('<small>%s</small>', $info[1]) : ''; ?> <?php $owner = $info[1]; ?> <a onclick="window.parent.send_to_editor('<?php echo $placeholder_key; ?> ')" data-owner="<?php echo sanitize_title($info[1]); ?> " title="<?php echo $placeholder_key; ?> " href="#"><?php printf('%s %s', WPDKGlyphIcons::html(WPDKGlyphIcons::ANGLE_LEFT), $info[0]); ?> </a> <?php } ?> </div> <script type="text/javascript"> (function ( $ ) { // Select var $select = $( '#wpdk-post-placeholder-select' ); // Display by owner $select.on( 'change', function () { if( empty( $( this ).val() ) ) { $( '.wpdk-post-placeholders' ).find( 'a,small' ).show(); } else { $( '.wpdk-post-placeholders' ).find( 'a,small' ).hide(); $( '.wpdk-post-placeholders' ).find( 'a[data-owner="'+ $( this ).val() +'"]' ).show(); } } ); })( jQuery ); </script> <?php }
/** * This is a utility method to display a common input type * * @brief Common input control * * @param string|WPDKHTMLTagInputType $type Optional. Type of input * @param string $class Optional. CSS additional class */ protected function inputType($type = WPDKHTMLTagInputType::TEXT, $class = '') { echo $this->contentWithKey('prepend'); // Create the label $label = $this->label(); // Display right label echo is_null($label) ? '' : $label->html(); $input = new WPDKHTMLTagInput('', $this->name, $this->id); $input->type = $type; $input->class = WPDKHTMLTag::mergeClasses($this->class, $class, trim('wpdk-form-input wpdk-ui-control ' . (is_null($label) ? 'wpdk-has-tooltip' : ''))); $input->style = WPDKHTMLTag::styleInline(isset($this->item['style']) ? $this->item['style'] : ''); $input->data = isset($this->item['data']) ? $this->item['data'] : ''; $input->value = isset($this->item['value']) ? $this->item['value'] : ''; $input->autocomplete = isset($this->item['autocomplete']) ? $this->item['autocomplete'] : null; $input->disabled = isset($this->item['disabled']) ? $this->item['disabled'] ? 'disabled' : null : null; $input->readonly = isset($this->item['readonly']) ? $this->item['readonly'] ? 'readonly' : null : null; $input->required = isset($this->item['required']) ? $this->item['required'] ? 'required' : null : null; $input->min = isset($this->item['min']) ? $this->item['min'] : ''; $input->max = isset($this->item['max']) ? $this->item['max'] : ''; $input->step = isset($this->item['step']) ? $this->item['step'] : ''; if (WPDKHTMLTagInputType::HIDDEN != $type) { $input->size = isset($this->item['size']) ? $this->item['size'] : $this->sizeForType($this->item['type']); $input->title = is_null($label) ? isset($this->item['title']) ? $this->item['title'] : '' : ''; $input->placeholder = isset($this->item['placeholder']) ? $this->item['placeholder'] : ''; } $input->setPropertiesByArray(isset($this->item['attrs']) ? $this->item['attrs'] : ''); if (isset($this->item['locked']) && true == $this->item['locked']) { $input->readonly = 'readonly'; } // Add a clear button icon for this types $add_clear_default_for_types = in_array($this->item['type'], array(WPDKUIControlType::DATE, WPDKUIControlType::DATETIME)); // And add the clear button if "add_clear" is set if ($add_clear_default_for_types || isset($this->item['add_clear'])) { // Add special class $input->class[] = 'wpdk-form-has-button-clear-left'; // Create icon clear $span_clear = new WPDKHTMLTagSpan(); $span_clear->class[] = 'wpdk-form-clear-left'; $span_clear->content = $input->html() . WPDKGlyphIcons::html(WPDKGlyphIcons::CANCEL_CIRCLED); $span_clear->display(); } else { $input->display(); } if (isset($this->item['locked']) && true == $this->item['locked']) { printf('<span title="%s" class="wpdk-form-locked wpdk-has-tooltip"></span>', __('This field is locked for your security. However you can unlock just by click here.', WPDK_TEXTDOMAIN)); } echo $this->contentWithKey('append'); echo ' ' . $this->guide(); }
/** * Return the HTML markup to display the delete row button. * * @brief Button delete row * * @return string */ private function buttonDelete() { WPDKHTML::startCompress(); ?> <button class="wpdk-dt-delete-row"> <?php WPDKGlyphIcons::display(WPDKGlyphIcons::MINUS_SQUARED); ?> </button> <?php return WPDKHTML::endHTMLCompress(); }