/** * Execute the plugin and return the markup for a version. * * @param object DOMDocument $versionXml * @return string * @access public * @since 1/7/08 */ public function executeAndGetVersionMarkup(DOMDocument $versionXml) { $this->setShowControls(false); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace(get_class($this) . ':' . $this->getId()); $this->_baseUrl = SiteDispatcher::mkURL(); $markup = $this->getVersionMarkup($versionXml); $harmoni->request->endNamespace(); return $markup; }
/** * Answer the markup for this comment. * * @param boolean $showThreadedReplies * @return string * @access public * @since 7/5/07 */ function getMarkup($showThreadedReplies) { $harmoni = Harmoni::instance(); ob_start(); print "\n\t<div class='comment' id='comment_" . $this->getIdString() . "'>"; print "<a name='" . $this->getIdString() . "'></a>"; if ($this->_enableEditForm) { print "<a name='" . RequestContext::name('current') . "'></a>"; } print "\n\t\t<div class='comment_display'>"; print "\n\t\t\t<form class='comment_controls' action='#' method='get'>"; $controls = array(); if ($this->canModify()) { ob_start(); print "\n\t\t\t\t<a href='#' onclick=\"this.parentNode.nextSibling.style.display='none'; this.parentNode.nextSibling.nextSibling.style.display='block'; return false;\">" . _("edit subject") . "</a>"; $controls[] = ob_get_clean(); ob_start(); $deleteUrl = SiteDispatcher::mkURL(); $deleteUrl->setValue('delete_comment', $this->getIdString()); print "\n\t\t\t\t<a "; print "href='" . $deleteUrl->write() . "#" . RequestContext::name('top') . "'"; print " onclick=\""; print "if (!confirm('" . _("Are you sure that you want to delete this comment?") . "')) { "; print "return false; "; print "}"; print "\">" . _("delete") . "</a>"; $controls[] = ob_get_clean(); } if ($this->hasContent() && $this->canReply()) { ob_start(); $replyUrl = SiteDispatcher::mkURL(); $replyUrl->setValue('reply_parent', $this->getIdString()); print "\n\t\t\t\t<a href='#' onclick=\"CommentPluginChooser.run(this, '" . $replyUrl->write() . "#" . RequestContext::name('current') . "', '" . rawurlencode(_('Re: ') . $this->getSubject()) . "'); return false;\">" . _("reply") . "</a>"; $controls[] = ob_get_clean(); } print implode(" | ", $controls); print "\n\t\t\t</form>"; print "<div class='comment_title'"; if ($this->canModify()) { print " onclick=\"this.style.display='none'; this.nextSibling.style.display='block'; this.nextSibling." . RequestContext::name('subject') . ".focus();\""; } print ">"; print $this->getSubject(); print "\n\t\t\t</div>"; if ($this->canModify()) { print "<form action='" . SiteDispatcher::quickURL() . "#" . RequestContext::name('top') . "'" . " method='post'"; print " style='display: none;'"; print " onsubmit=\""; print "updateCommentSubject (this, this.previousSibling); "; print "this.style.display='none'; "; print "this.previousSibling.style.display='block'; "; print "return false; \""; print ">"; print "\n\t\t\t\t<input type='text' name='" . RequestContext::name('subject') . "' value=\"" . $this->getSubject() . "\"/>"; print "\n\t\t\t\t<input type='hidden' name='" . RequestContext::name('comment_id') . "' value=\"" . $this->getIdString() . "\"/>"; print "\n\t\t\t\t<input type='submit' name='" . RequestContext::name('submit') . "' value=\"" . _("Update Subject") . "\"/>"; print "\n\t\t\t\t<input type='button' name='" . RequestContext::name('cancel') . "' value=\"" . _("Cancel") . "\" onclick=\"this.parentNode.style.display='none'; this.parentNode.previousSibling.style.display='block'; return false;\"/>"; print "\n\t\t\t</form>"; } print "\n\t\t\t<div class='comment_byline'>"; $author = $this->getAuthor(); $date = $this->getCreationDate(); $dateString = $date->dayOfWeekName() . " " . $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year(); $time = $date->asTime(); print str_replace('%1', $author->getDisplayName(), str_replace('%2', $dateString, str_replace('%3', $time->string12(), _("by %1 on %2 at %3")))); print "\n\t\t\t</div>"; print "\n\t\t\t<div class='comment_body'>"; print $this->getBody(); print "\n\t\t\t</div>"; print "\n\t\t</div>"; if ($showThreadedReplies) { print "\n\t\t<div class='comment_replies'>"; $replies = $this->getReplies(ASC); while ($replies->hasNext()) { $reply = $replies->next(); // If this is a work in progress that has not had content added yet, // do not display it. if ($reply->hasContent() || $reply->isAuthor()) { print "\n\t\t\t\t<img src='" . MYPATH . "/images/reply_indent.png' class='reply_icon' alt='" . _('reply') . "'/>"; print "\n\t\t\t<div class='comment_reply'>"; print $reply->getMarkup(true); print "\n\t\t\t</div>"; } } print "\n\t\t</div>"; } print "\n\t</div>"; return ob_get_clean(); }
/** * Answer the interface markup needed to display the comments attached to the * given asset. * * @param object Asset $asset * @return string * @access public * @since 7/3/07 */ function getMarkup($asset) { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace('comments'); if (RequestContext::value('order')) { $this->setDisplayOrder(RequestContext::value('order')); } if (RequestContext::value('displayMode')) { $this->setDisplayMode(RequestContext::value('displayMode')); } try { if (RequestContext::value('create_new_comment')) { $comment = $this->createRootComment($asset, HarmoniType::fromString(RequestContext::value('plugin_type'))); $comment->updateSubject(RequestContext::value('title')); $comment->enableEditForm(); } if (RequestContext::value('reply_parent') && RequestContext::value('plugin_type')) { $idManager = Services::getService('Id'); $comment = $this->createReply($idManager->getId(RequestContext::value('reply_parent')), HarmoniType::fromString(RequestContext::value('plugin_type'))); $comment->updateSubject(RequestContext::value('title')); $comment->enableEditForm(); } if (RequestContext::value('delete_comment')) { $idManager = Services::getService('Id'); try { $this->deleteComment($idManager->getId(RequestContext::value('delete_comment'))); } catch (Exception $e) { // In case we have a delete_comment id in the url that no longer exists, // just catch any exceptions. See the following bug: // http://sourceforge.net/tracker/index.php?func=detail&aid=1798996&group_id=82171&atid=565234 } } } catch (PermissionDeniedException $e) { $messages = $e->getMessage(); } $this->addHead(); ob_start(); if (isset($messages)) { print "\n<div class='error'>" . $messages . "</div>"; } if ($this->canComment($asset->getId())) { // New comment print "\n<div style='float: left;'>"; $url = SiteDispatcher::mkURL(); $url->setValue('create_new_comment', 'true'); print "\n\t<button "; print "onclick=\"CommentPluginChooser.run(this, '" . $url->write() . "#" . RequestContext::name('current') . "', ''); return false;\">"; print _("New Post") . "</button>"; print "\n<div class='comment_help'>"; print _("Discussion posts can be edited or deleted until they are replied-to."); print " (" . Help::link('Discussion') . ")"; print "</div>"; print "\n</div>"; } if ($this->canViewComments($asset->getId())) { // print the ordering form if ($this->isSortingEnabled()) { print "\n\n<form action='" . SiteDispatcher::quickURL() . "#" . RequestContext::name('top') . "' method='post' style='float: right; text-align: right;'>"; print "\n\t\t<select name='" . RequestContext::name('displayMode') . "'>"; print "\n\t\t\t<option value='threaded'" . ($this->getDisplayMode() == 'threaded' ? " selected='selected'" : "") . ">"; print _("Threaded") . "</option>"; print "\n\t\t\t<option value='flat'" . ($this->getDisplayMode() == 'flat' ? " selected='selected'" : "") . ">"; print _("Flat") . "</option>"; print "\n\t\t</select>"; print "\n\t\t<select name='" . RequestContext::name('order') . "'>"; print "\n\t\t\t<option value='" . ASC . "'" . ($this->getDisplayOrder() == ASC ? " selected='selected'" : "") . ">"; print _("Oldest First") . "</option>"; print "\n\t\t\t<option value='" . DESC . "'" . ($this->getDisplayOrder() == DESC ? " selected='selected'" : "") . ">"; print _("Newest First") . "</option>"; print "\n\t\t</select>"; print "\n\t<input type='submit' value='" . _("Change") . "'/>"; print "\n</form>"; print "\n<div style='clear: both;'> </div>"; } // Print out the Comments print "\n<div id='" . RequestContext::name('comments') . "'>"; if ($this->getDisplayMode() == 'flat') { $comments = $this->getAllComments($asset, $this->getDisplayOrder()); } else { $comments = $this->getRootComments($asset, $this->getDisplayOrder()); } while ($comments->hasNext()) { $comment = $comments->next(); // If this is a work in progress that has not had content added yet, // do not display it. if ($comment->hasContent() || $comment->isAuthor()) { print $comment->getMarkup($this->getDisplayMode() == 'threaded' ? true : false); } } print "\n</div>"; } else { print "\n<div>" . _("You are not authorized to view discussion posts.") . "</div>"; } $harmoni->request->endNamespace(); return ob_get_clean(); }
/** * Print the edit controls * * @param object SiteComponent $siteComponent * @return void * @access public * @since 5/7/07 */ function getEdit($siteComponent, $action) { ob_start(); $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $harmoni = Harmoni::instance(); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteComponent->getQualifierId())) { // if parent is flow organizer and rows are limited then // get pages of $parent = $siteComponent->getParentComponent(); $parent->getId(); $url = SiteDispatcher::mkURL('ui1', $action, array('node' => $siteComponent->getId(), 'returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->action)); print "\n\t\t\t\t\t<a href='" . $url->write() . "'>"; print _("edit"); print "</a>"; } return ob_get_clean(); }
/** * Answer a url for Ajax updating * * @param array $parameters Associative array ('name' => 'value') * @return string * @access public * @since 1/17/06 */ private function _ajaxUrl($parameters = array()) { $harmoni = Harmoni::instance(); $url = SiteDispatcher::mkURL($this->updateModule, $this->updateAction); $harmoni->request->startNamespace('plugin_manager'); $url->setValue('plugin_id', $this->getId()); // Local modules and actions for generating valid links if (isset($this->localModule) && $this->localModule) { $url->setValue('module', $this->localModule); } else { $url->setValue('module', $harmoni->request->getRequestedModule()); } if (isset($this->localAction) && $this->localAction) { $url->setValue('action', $this->localAction); } else { $url->setValue('action', $harmoni->request->getRequestedAction()); } if ($this->_isExtended) { $url->setValue('extended', 'true'); } $harmoni->request->endNamespace(); if (is_array($parameters) && count($parameters)) { $url->setValues($parameters); } return $url->write(); }