/** * A widget that lists all comments for a given recipe * @param Recipe $recipe A recipe object **/ public function __construct($recipe) { $GLOBALS['RTK']->AddJavascript('/commentview.js'); parent::__construct('CommentView'); if (is_a($recipe, 'Recipe')) { $this->AddChild(new RTK_Header('Comments')); $comments = Comment::LoadComments('R=' . $recipe->GetId()); $box = null; if (sizeof($comments) > 0) { $box = new RTK_Box('Comments'); $this->TraverseComment($box, $comments); } else { if (Login::IsLoggedIn()) { $message = 'No comments yet, be the first to comment on this recipe!'; } else { $message = 'No comments yet, log in and be the first to comment on this recipe!'; } $box = new RTK_Textview($message, false, null, 'commentnone'); } if (Site::HasHttps() && Login::IsLoggedIn()) { $form = new RTK_Form('CommentForm'); $form->AddChild($box); $inputbox = new RTK_Box('NewComment'); $inputbox->AddChild(new HtmlElement('a', array('href' => '#', 'onclick' => 'SelectComment(\'\')'), 'New comment')); $inputbox->AddChild(new HtmlElement('input', array('name' => 'CommentSelect', 'id' => 'CommentSelect', 'type' => 'hidden'))); $inputbox->AddChild(new HtmlElement('input', array('name' => 'CommentInput', 'id' => 'CommentInput', 'type' => 'text', 'autocomplete' => 'off'))); $inputbox->AddChild(new RTK_Button('submit', 'Send')); $form->AddChild($inputbox); $this->AddChild($form); } else { $this->AddChild($box); } } }
/** * A widget that lists all comments for a given article * @param string $articleid The id of the article **/ public function __construct($articleid) { parent::__construct('CommentView'); $this->AddJavascript(RTK_DIRECTORY . 'script/rtk-commentview.js'); if ($articleid != null) { $this->AddChild(new RTK_Header('Comments')); $this->_display = new HtmlElement(); $this->_commentbox = new RTK_Box('Comments'); $this->_comments = Comment::LoadComments($articleid); if (sizeof($this->_comments) > 0) { $this->TraverseComment($this->_commentbox, $this->_comments); } if (Login::IsLoggedIn()) { $message = 'No comments yet, be the first to comment on this recipe!'; } else { $message = 'No comments yet, log in and be the first to comment on this recipe!'; } $this->_nocomments = new RTK_Textview($message, false, null, 'commentnone'); if (Site::HasHttps() && Login::IsLoggedIn()) { $form = new RTK_Form('CommentForm', EMPTYSTRING, 'POST', true, array('autocomplete' => 'off')); $form->AddChild($this->_commentbox); $inputbox = new RTK_Box('NewComment'); $inputbox->AddChild(new HtmlElement('a', array('href' => '#', 'onclick' => 'SelectComment(\'\')'), 'New comment')); $inputbox->AddChild(new HtmlElement('input', array('name' => 'CommentSelect', 'id' => 'CommentSelect', 'type' => 'hidden'))); $inputbox->AddChild(new HtmlElement('input', array('name' => 'CommentInput', 'id' => 'CommentInput', 'type' => 'text', 'autocomplete' => 'off'))); $inputbox->AddChild(new RTK_Button('submit', 'Send')); $form->AddChild($inputbox); $this->_commentbox = $form; } $this->AddChild($this->_display); } }