public function renderStars(Comment $comment) { if (!$this->options['useStars']) { return ''; } if (!$comment->stars) { return ''; } $commentStars = new CommentStars(); return $commentStars->render($comment->stars, false); }
protected function renderFormThread($id, $class, $attrs, $labels, $inputValues) { $form = "\n<form class='{$class} CommentFormThread' action='{$attrs['action']}#{$id}' method='{$attrs['method']}'>" . "\n\t<p class='CommentFormCite {$id}_cite'>" . "\n\t\t<label>" . "\n\t\t\t<span>{$labels['cite']}</span> " . "\n\t\t\t<input type='text' name='cite' class='required' required='required' value='{$inputValues['cite']}' maxlength='128' />" . "\n\t\t</label> " . "\n\t</p>" . "\n\t<p class='CommentFormEmail {$id}_email'>" . "\n\t\t<label>" . "\n\t\t\t<span>{$labels['email']}</span> " . "\n\t\t\t<input type='email' name='email' class='required email' required='required' value='{$inputValues['email']}' maxlength='255' />" . "\n\t\t</label>" . "\n\t</p>"; if ($this->commentsField && $this->commentsField->useWebsite && $this->commentsField->schemaVersion > 0) { $form .= "\n\t<p class='CommentFormWebsite {$id}_website'>" . "\n\t\t<label>" . "\n\t\t\t<span>{$labels['website']}</span> " . "\n\t\t\t<input type='text' name='website' class='website' value='{$inputValues['website']}' maxlength='255' />" . "\n\t\t</label>" . "\n\t</p>"; } if ($this->commentsField->useStars && $this->commentsField->schemaVersion > 5) { $commentStars = new CommentStars(); $starsClass = 'CommentFormStars'; if ($this->commentsField->useStars > 1) { $starsNote = $labels['starsRequired']; $starsClass .= ' CommentFormStarsRequired'; } else { $starsNote = ''; } $form .= "\n\t<p class='{$starsClass} {$id}_stars' data-note='{$starsNote}'>" . "\n\t\t<label>" . "\n\t\t\t<span>{$labels['stars']}</span>" . "\n\t\t\t<input type='number' name='stars' id='{$id}_stars' value='{$inputValues['stars']}' min='0' max='5' />" . "\n\t\t\t" . $commentStars->render(0, true) . "\n\t\t</label>" . "\n\t</p>"; } $form .= "\n\t<p class='CommentFormText {$id}_text'>" . "\n\t\t<label>" . "\n\t\t\t<span>{$labels['text']}</span>" . "\n\t\t\t<textarea name='text' class='required' required='required' rows='{$attrs['rows']}' cols='{$attrs['cols']}'>{$inputValues['text']}</textarea>" . "\n\t\t</label>" . "\n\t</p>" . $this->renderNotifyOptions() . "\n\t<p class='CommentFormSubmit {$id}_submit'>" . "\n\t\t<button type='submit' name='{$id}_submit' value='1'>{$labels['submit']}</button>" . "\n\t\t<input type='hidden' name='page_id' value='{$this->page->id}' />" . "\n\t\t<input type='hidden' class='CommentFormParent' name='parent_id' value='0' />" . "\n\t</p>" . "\n</form>"; return $form; }
/** * Render combined star rating for all comments in this CommentsArray * * @param bool $showCount Specify true to include how many ratings the average is based on * @param array $options Overrides of stars and/or count, see $defaults in method * @return string * */ public function renderStars($showCount = false, $options = array()) { $defaults = array('stars' => null, 'count' => null, 'blank' => true, 'partials' => true, 'schema' => '', 'input' => false); $options = array_merge($defaults, $options); if (!is_null($options['stars'])) { $stars = $options['stars']; $count = (int) $options['count']; } else { list($stars, $count) = $this->stars($options['partials'], true); } if (!$count && $options['blank']) { return ''; } $commentStars = new CommentStars(); $out = $commentStars->render($stars, $options['input']); if ($showCount) { $out .= $commentStars->renderCount((int) $count, $stars, $options['schema']); } return $out; }