function emit() { /* For all other items, build a table row */ /* Row container */ print '<tr '; print ' class="form-item-row form-item-' . $this->type . '-row" '; print ' id="' . $this->id . '-row" '; if (null != $this->rowStyle) { print ' style="' . $this->rowStyle . '" '; } print '>' . "\n"; /* Prefix cell */ print '<td '; print ' class="form-item-prefix" '; print ' id="' . $this->id . '-prefix" '; print '>'; if (null != $this->prefix) { print $this->prefix; } print '</td>'; /* Label cell (if not raw HTML content) */ if ($this->type != FORM_ITEM_RAW) { print '<td '; print ' class="form-item form-item-label" '; print ' id="' . $this->id . '-label" '; print '>'; /* Radio buttons have label on the inside... */ if (null != $this->label && $this->type != FORM_ITEM_RADIO) { print '<label class="form-item-label" for="' . $this->id . '">' . $this->label . "</label>\n"; } print '</td>'; /* Contents cell */ print '<td '; print ' class="form-item-contents" '; print ' id="' . $this->id . '-contents" '; print '>'; } else { // For RAW, both cells are the raw content print '<td class="form-item-raw" colspan="2">'; } /* Switch on type */ switch ($this->type) { case FORM_ITEM_RAW: // Extra bits inside the form... print '<div '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-raw" '; if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print '>'; print $this->value; print '</div>'; break; case FORM_ITEM_HIDDEN: // Hidden field for passing data print '<input '; print ' type="hidden" '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-hidden" '; print ' name="' . $this->name . '" '; print ' value="' . $this->value . '" '; if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; break; case FORM_ITEM_TEXT: // Simple text entry print '<input '; print ' type="text" '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-text" '; print ' name="' . $this->name . '" '; print ' value="' . $this->value . '" '; if (null != $this->hsize) { print 'size="' . $this->hsize . '" '; } print ' maxlength="' . $this->max_hsize . '" '; if (null != $this->hint) { print 'placeholder="' . $this->hint . '" '; } if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; break; case FORM_ITEM_CHECK: // Checkbox print '<input '; print ' type="checkbox" '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-check" '; print ' name="' . $this->name . '" '; if ($this->value == FORM_VALUE_CHECKED) { print 'checked '; } print ' value="' . $this->value . '" '; if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; break; case FORM_GROUP_BOOLEAN: // Boolean control for item grouping; implement (for now) as a // checkbox with an invisible span for storage. The form method // to start a new group must have added the controlling event. print '<input '; print ' type="checkbox" '; print ' id="' . $this->id . '" '; print ' class="form-item form-group-boolean" '; print ' name="' . $this->name . '" '; if ($this->value == FORM_VALUE_CHECKED) { print 'checked '; } print ' value="' . $this->value . '" '; if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; // Tag storage here print '<span '; print ' id="' . $this->id . '-storage" '; print ' class="form-item-storage" '; print ' style="display:none;" '; print '>'; foreach ($this->options as $ref) { print $ref->tag . ','; } print '</span>'; break; case FORM_ITEM_DATE: // Date item; text entry + datepicker print '<input '; print ' type="text" '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-text" '; print ' name="' . $this->name . '" '; print ' value="' . $this->value . '" '; if (null != $this->hsize) { print 'size="' . $this->hsize . '" '; } print ' maxlength="' . $this->max_hsize . '" '; if (null != $this->hint) { print 'placeholder="' . $this->hint . '" '; } if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; print '<a class="frameless" title="Select a date" href="javascript:">'; skin_img("form-datepick.png", "Select a date", "frameless", $this->id . "-trigger"); print '</a>'; print "\n" . '<script type="text/javascript">' . "\n"; print "akForm_registerPopup('" . $this->id . "','" . $this->id . "-trigger','form-date',null);\n"; print '</script>'; break; case FORM_ITEM_TIME: // Time item: hidden field to store value, with // selectors for components. // CLEAN: TODO: Use input value to set fields. // Hidden field for passing data print '<input '; print ' type="hidden" '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-hidden" '; print ' name="' . $this->name . '" '; //print ' value="'.$this->value.'" '; print ' value="190000" '; if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; // Hour selector print '<select '; print ' id="' . $this->id . '-hour" '; print ' class="form-item form-item-time" '; print ' name="' . $this->name . '-hour" '; print ' onChange="akForm_timepickerChange(\'' . $this->id . '\');"'; print '>'; print '<option value="12">12</option>' . "\n"; for ($iter = 1; $iter < 12; $iter++) { print '<option '; if ($iter == 7) { print 'selected="true" '; } print 'value="' . $iter . '">' . $iter . '</option>' . "\n"; } print '</select>'; // Minute selector print '<select '; print ' id="' . $this->id . '-minute" '; print ' class="form-item form-item-time" '; print ' name="' . $this->name . '-minute" '; print ' onChange="akForm_timepickerChange(\'' . $this->id . '\');"'; print '>'; print '<option value="0" selected="true">:00</option>' . "\n"; print '<option value="15">:15</option>' . "\n"; print '<option value="30">:30</option>' . "\n"; print '<option value="45">:45</option>' . "\n"; print '</select>'; // AM/PM selector print '<select '; print ' id="' . $this->id . '-ampm" '; print ' class="form-item form-item-time" '; print ' name="' . $this->name . '-ampm" '; print ' onChange="akForm_timepickerChange(\'' . $this->id . '\');"'; print '>'; print '<option value="0">AM</option>' . "\n"; print '<option value="12" selected="true">PM</option>' . "\n"; print '</select>'; // noon/midnight indicator print '<span class="form-item-note" id="' . $this->id . '-note">'; print '</span>'; break; case FORM_ITEM_TEXTAREA: // Multiline text entry print '<textarea '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-textarea" '; print ' name="' . $this->name . '" '; if (null != $this->hsize) { print 'cols="' . $this->hsize . '" '; } if (null != $this->vsize) { print 'rows="' . $this->vsize . '" '; } if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; print $this->value; print '</textarea>'; break; case FORM_ITEM_SELECT: print '<select '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-select" '; print ' name="' . $this->name . '" '; if (null != $this->hsize) { print 'size="' . $this->hsize . '" '; } if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print ">\n"; if ($this->options != null) { foreach ($this->options as $option) { print '<option '; print 'value="' . $option->tag . '" '; if ($option->is_selected) { print 'selected="true" '; } print '>'; print $option->label; print '</option>' . "\n"; } } print '</select>'; break; case FORM_ITEM_RADIO: // Radio button print '<input '; print ' type="radio" '; //print ' id="'.$this->id.'" '; print ' class="form-item form-item-radio" '; print ' name="' . $this->name . '" '; print ' value="' . $this->value . '" '; if (null != $this->hint) { print ' checked="' . $this->hint . '" '; } if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>" . $this->label . "\n"; break; case FORM_ITEM_PASSWORD: // Password field print '<input '; print ' type="password" '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-password" '; print ' name="' . $this->name . '" '; print ' value="' . $this->value . '" '; if (null != $this->hsize) { print 'size="' . $this->hsize . '" '; } print ' maxlength="' . $this->max_hsize . '" '; if (null != $this->hint) { print ' placeholder="' . $this->hint . '" '; } if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; break; case FORM_ITEM_BUTTON: // Generic button (remember to add an onClick event) print '<input '; print ' type="button" '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-button" '; print ' name="' . $this->name . '" '; print ' value="' . $this->value . '" '; if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; break; case FORM_ITEM_SUBMIT: // Submit button print '<input '; print ' type="submit" '; print ' id="' . $this->id . '" '; print ' class="form-item form-item-submit" '; print ' name="' . $this->name . '" '; print ' value="' . $this->value . '" '; if (null != $this->style) { print 'style="' . $this->style . '" '; } foreach (array_keys($this->events) as $evkey) { print $evkey . '="' . $this->events[$evkey] . '" '; } print "/>\n"; break; } print '</td>'; // Suffix cell print '<td '; print ' class="form-item-suffix" '; print ' id="' . $this->id . '-suffix" '; print '>'; if (null != $this->suffix) { print $this->suffix; } print '</td>'; print '</tr>' . "\n"; }
function emit() { /* If there's a link, wrap it */ if (null != $this->url) { print '<a '; print ' class="story-link" '; print ' href="' . $this->url . '" '; if (null != $this->alt) { print ' title="' . $this->alt . '" '; } print '>'; } /* Switch on type */ switch ($this->type) { case STORY_CHUNK_HEADLINE: print '<h1 '; print ' class="story-headline" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>' . $this->value . '</h1>'; break; case STORY_CHUNK_SECTION: print '<div class="closure_div"></div>'; print '<h2 '; print ' class="story-headline" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>' . $this->value . '</h2>'; break; case STORY_CHUNK_GROUP: print '<div class="closure_div"></div>'; print '<h3 '; print ' class="story-headline" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>' . $this->value . '</h3>'; break; case STORY_CHUNK_SUBGROUP: print '<h4 '; print ' class="story-headline" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>' . $this->value . '</h4>'; break; case STORY_CHUNK_LEDE: print '<img '; print ' class="story-lede" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } if (null != $this->alt) { print ' alt="' . $this->alt . '" '; } print ' src="' . $this->value . '" '; print '/>'; break; case STORY_CHUNK_BANNER: print '<img '; print ' class="story-banner" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } if (null != $this->alt) { print ' alt="' . $this->alt . '" '; } print ' src="' . $this->value . '" '; print '/>'; break; case STORY_CHUNK_TEXT: print '<span '; print ' class="story-span" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; print $this->value; print "\n</span>"; break; case STORY_CHUNK_ERROR: print '<span '; print ' class="story-error" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; print $this->value; print "\n</span>"; break; case STORY_CHUNK_WARNING: print '<span '; print ' class="story-warning" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; print $this->value; print "\n</span>"; break; case STORY_CHUNK_META: print '<span '; print ' class="story-meta" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; print $this->value; print "\n</span>"; break; case STORY_CHUNK_FILE: /* If the user is logged in, add an editor button */ if (is_authenticated() && is_editor()) { print '<a '; print ' href="/edit-story-file.php?file=' . $this->value . '" '; print ' class="story-trail" '; print ' title="Edit this text" '; print '>'; skin_img("edit_icon.png", "Edit this text", "story-trail"); print '</a>'; } print '<span '; print ' class="story-span" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; /* Verify that we can read it */ if (!is_readable($this->value)) { print "[[I can't import text from \"" . $this->value . "\", because I can't find it (or can't read it). Sorry 'bout that.]]"; } else { @(include $this->value); } print "\n</span>"; break; case STORY_CHUNK_OBJECT: print '<div '; print ' class="story-object" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>'; $this->object->emit(); print '</div>'; } /* Finish the link (if any) */ if (null != $this->url) { print "</a>"; } /* Add the newline */ print "\n"; }