1: <?php
  2: 
  3:   4:   5: 
  6: class Quform_Shortcode
  7: {
  8:       9:  10: 
 11:     protected $controller;
 12: 
 13:      14:  15: 
 16:     protected $options;
 17: 
 18:      19:  20:  21: 
 22:     public function __construct(Quform_Form_Controller $controller, Quform_Options $options)
 23:     {
 24:         $this->controller = $controller;
 25:         $this->options = $options;
 26:     }
 27: 
 28:      29:  30:  31:  32:  33: 
 34:     public function form($attributes)
 35:     {
 36:         $options = shortcode_atts(array(
 37:             'id' => '',
 38:             'values' => '',
 39:             'show_title' => '1',
 40:             'show_description' => '1'
 41:         ), $attributes);
 42: 
 43:         $options['show_title'] = $options['show_title'] == '1';
 44:         $options['show_description'] = $options['show_description'] == '1';
 45: 
 46:         $output = $this->controller->form($options);
 47: 
 48:         if ($this->options->get('rawFix')) {
 49:             $output = '[raw]' . $output . '[/raw]';
 50:         }
 51: 
 52:         return $output;
 53:     }
 54: 
 55:      56:  57:  58:  59:  60:  61: 
 62:     public function popup($attributes, $content = '')
 63:     {
 64:         $options = shortcode_atts(array(
 65:             'id' => '',
 66:             'values' => '',
 67:             'options' => '',
 68:             'width' => '',
 69:             'show_title' => '1',
 70:             'show_description' => '1'
 71:         ), $attributes);
 72: 
 73:         $options['show_title'] = $options['show_title'] == '1';
 74:         $options['show_description'] = $options['show_description'] == '1';
 75:         $options['popup'] = true;
 76:         $options['content'] = $content;
 77: 
 78:         $output = $this->controller->form($options);
 79: 
 80:         if ($this->options->get('rawFix')) {
 81:             $output = '[raw]' . $output . '[/raw]';
 82:         }
 83: 
 84:         return $output;
 85:     }
 86: 
 87:      88:  89:  90:  91:  92: 
 93:     public function entryLimit($attributes) {
 94:         $options = shortcode_atts(array(
 95:             'id' => '',
 96:         ), $attributes);
 97: 
 98:         return esc_html($this->controller->getEntryLimit((int) $options['id']));
 99:     }
100: 
101:     102: 103: 104: 105: 106: 
107:     public function entryCount($attributes) {
108:         $options = shortcode_atts(array(
109:             'id' => '',
110:         ), $attributes);
111: 
112:         return esc_html($this->controller->getEntryCount((int) $options['id']));
113:     }
114: 
115:     116: 117: 118: 119: 120: 
121:     public function entriesRemaining($attributes) {
122:         $options = shortcode_atts(array(
123:             'id' => '',
124:         ), $attributes);
125: 
126:         return esc_html($this->controller->getEntriesRemaining((int) $options['id']));
127:     }
128: }
129: