Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
design_area_searchbox.inc
1 <?php
17 require_once SQ_CORE_PACKAGE_PATH.'/designs/design_area/design_area.inc';
18 require_once SQ_LIB_PATH.'/html_form/html_form.inc';
19 
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  parent::__construct($assetid);
44 
45  }//end constructor
46 
47 
55  function _canInit()
56  {
57  $assetid = $this->attr('search_page_assetid');
58  return !($assetid <= 0);
59 
60  }//end _canInit()
61 
62 
74  function printVar($var, $args, $value_prefix='', $value_suffix='')
75  {
76  $assetid = $this->attr('search_page_assetid');
77  if (empty($assetid)) return;
78  $am =& $GLOBALS['SQ_SYSTEM']->am;
79  $asset = $am->getAsset($assetid);
80 
81  switch ($var) {
82 
83  case 'form_start' :
84  echo '
85  <?php $asset = $GLOBALS["SQ_SYSTEM"]->am->getAsset('.$asset->id.'); ?>
86  <form method="get" action="<?php echo $asset->getURL(); ?>">
87  ';
88  break;
89 
90  case 'form_end' :
91  echo '</form>';
92  break;
93 
94  case 'submit' :
95  if ($this->attr('submit_button')) {
96  $class = isset($args['class']) ? ' class="'.$args['class'].'"' : '';
97 
98  $button_value = $this->attr('submit_button_text');
99  echo '<input type="submit" value="'.$button_value.'"'.$class.' />';
100 
101  } else {
102  $submit_image_assetid = $this->attr('submit_image_assetid');
103  if ($submit_image_assetid > 0) {
104  $submit_image_asset = $am->getAsset($submit_image_assetid);
105  echo '<'.'?php $submit_image_asset = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset('.$submit_image_asset->id.', "'.$submit_image_asset->type().'"); ?'.'>';
106  echo '<input alt="'.$this->attr('submit_button_text').'" type="image"';
107  if (isset($args['class'])) {
108  echo ' class="'.$args['class'].'"';
109  }
110  echo ' src="<'.'?php echo $submit_image_asset->getURL(); ?'.'>" />';
111  } else {
112  // no image defined
113  }
114  }
115  break;
116 
117  case 'category_list':
118  $category_set = $this->attr('category_set');
119  $default = $this->attr('category_default');
120  $show_empty = $this->attr('category_show_empty');
121  if (!empty($category_set)) {
122  echo '
123  <?php
124  $asset = $GLOBALS["SQ_SYSTEM"]->am->getAsset('.$asset->id.');
125  $categories = $asset->attr("categories");
126  echo $asset->getCategoryChooserReplacement("'.$category_set.'", $categories["'.$category_set.'"], "'.$default.'", '.var_export($show_empty, TRUE).');
127  ?>';
128  }
129 
130  break;
131 
132  case 'box' :
133  $class = isset($args['class']) ? ' class="'.$args['class'].'"' : '';
134  $id = isset($args['id']) ? ' id="'.$args['id'].'"' : '';
135 
136  $title_val = $this->attr('querybox_title');
137  $title = !empty($title_val) ? ' title="'.$this->attr('querybox_title').'"' : '';
138 
139  $label_val = $this->attr('querybox_label');
140  $label = '';
141  if (!empty($label_val)) {
142  if (!empty($args['id'])) {
143  $label = '<label for="'.$args['id'].'">'.$this->attr('querybox_label').'</label>';
144  } else {
145  $label = '<label for="'.htmlspecialchars($this->attr('field_name')).'">'.$this->attr('querybox_label').'</label>';
146  }
147  }
148  echo '
149  <input type="hidden" name="mode" value="results" />
150  <?php
151  $asset = $GLOBALS["SQ_SYSTEM"]->am->getAsset('.$asset->id.');
152 
153  $field_name = "'.$this->attr('field_name').'";
154  $box_width = '.$this->attr('querybox_width').';
155  if (!empty($field_name)) {
156  $form_field_name = "queries_".$field_name."_query";
157  $field_value = $asset->getQueryFieldValue($field_name);
158 
159  if (empty($field_value)) {
160  $field_value = "'.$this->attr('default_text').'";
161  $hide_default = true;
162  } else {
163  $hide_default = false;
164  }
165 
166  require_once SQ_LIB_PATH."/html_form/html_form.inc";
167  '.(!empty($label) ? 'echo \''.$label.'\';' : '').'
168  text_box($form_field_name, $field_value, $box_width, "", $hide_default, \''.$class.$id.$title.'\');
169  }
170  ?>
171  ';
172  break;
173 
174  default:
175  if (substr($var, -6) == '_query') {
176  echo '
177  <?php
178  $asset = $GLOBALS["SQ_SYSTEM"]->am->getAsset('.$asset->id.');
179  echo $asset->getFieldReplacement("'.substr($var, 0, -6).'");
180  ?>';
181  } else if (substr($var, -17) == '_category_chooser') {
182  echo '
183  <?php
184  $asset = $GLOBALS["SQ_SYSTEM"]->am->getAsset('.$asset->id.');
185  $categories = $asset->attr("categories");
186  echo $asset->getCategoryChooserReplacement("'.substr($var, 0, -17).'", $categories["'.substr($var, 0, -17).'"]);
187  ?>';
188  }
189  break;
190 
191  }//end switch
192 
193  }//end printVar()
194 
195 
196 }//end class
197 
198 ?>