Commit 966247783b4e6a62d2035a92d9c7b2a29b26b04a
1 parent
8108c83d
Add document addition observers that control the UI component of
document addition. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4406 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
114 additions
and
0 deletions
lib/documentmanagement/observers.inc.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +class KTMultipartPageObserver { | ||
| 4 | + function KTMultipartPageObserver() { | ||
| 5 | + $this->boundary = md5(time()); | ||
| 6 | + } | ||
| 7 | + | ||
| 8 | + function start() { | ||
| 9 | + ob_implicit_flush(); | ||
| 10 | + header(sprintf("Content-type: multipart/mixed; boundary=%s", $this->boundary)); | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + function receiveMessage(&$msg) { | ||
| 14 | + printf("\n--%s\n", $this->boundary); | ||
| 15 | + echo "Content-Type: text/html\n\n"; | ||
| 16 | + | ||
| 17 | + print $msg->getString(); | ||
| 18 | + print "\n"; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + function redirect($location) { | ||
| 22 | + printf("\n--%s\n", $this->boundary); | ||
| 23 | + echo "Content-Type: text/html\n\n"; | ||
| 24 | + printf("Location: %s\n", $location); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + function end() { | ||
| 28 | + printf("\n--%s--\n", $this->boundary); | ||
| 29 | + } | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +class JavascriptObserver { | ||
| 33 | + function JavascriptObserver(&$context) { | ||
| 34 | + $this->context = $context; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + function start() { | ||
| 38 | + $this->context->oPage->requireJSResource('thirdpartyjs/MochiKit/Base.js'); | ||
| 39 | + $this->context->oPage->requireJSResource('thirdpartyjs/MochiKit/Iter.js'); | ||
| 40 | + $this->context->oPage->requireJSResource('thirdpartyjs/MochiKit/DOM.js'); | ||
| 41 | + $this->context->oPage->requireJSResource('resources/js/add_document.js'); | ||
| 42 | + $this->context->oRedirector =& $this; | ||
| 43 | + $this->context->handleOutput('<div id="kt-add-document-target"> </div>'); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + function receiveMessage(&$msg) { | ||
| 47 | + if (is_a($msg, 'KTUploadNewFile')) { | ||
| 48 | + printf('<script language="javascript">kt_add_document_newFile("%s")</script>', $msg->getString()); | ||
| 49 | + return; | ||
| 50 | + } | ||
| 51 | + printf('<script language="javascript">kt_add_document_addMessage("%s")</script>', $msg->getString()); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + function redirectToDocument($id) { | ||
| 55 | + printf('<script language="javascript">kt_add_document_redirectToDocument("%d")</script>', $id); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + function redirectToFolder($id) { | ||
| 59 | + printf('<script language="javascript">kt_add_document_redirectToFolder("%d")</script>', $id); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + function redirect($url) { | ||
| 63 | + printf('<script language="javascript">kt_add_document_redirectTo("%s")</script>', $url); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + function end() { | ||
| 68 | + printf("\n--%s--\n", $this->boundary); | ||
| 69 | + } | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +class KTSinglePageObserver { | ||
| 73 | + function KTSinglePageObserver(&$context) { | ||
| 74 | + $this->context =& $context; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + function start() { | ||
| 78 | + $this->context->oPage->template = 'kt3/minimal_page'; | ||
| 79 | + $this->context->oRedirector =& $this; | ||
| 80 | + $this->context->handleOutput(""); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + function receiveMessage(&$msg) { | ||
| 84 | + if (is_a($msg, 'KTUploadNewFile')) { | ||
| 85 | + print "<h2>" . $msg->getString() . "</h2>"; | ||
| 86 | + return; | ||
| 87 | + } | ||
| 88 | + print "<div>" . $msg->getString() . "</div>\n"; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + function redirectToDocument($id) { | ||
| 92 | + $url = generateControllerUrl("viewDocument", sprintf("fDocumentId=%d", $id)); | ||
| 93 | + printf('Go <a href="%s">here</a> to continue', $url); | ||
| 94 | + printf("</div></div>\n"); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + function redirectToFolder($id) { | ||
| 98 | + $url = generateControllerUrl("browse", sprintf("fFolderId=%d", $id)); | ||
| 99 | + printf('Go <a href="%s">here</a> to continue', $url); | ||
| 100 | + printf("</div></div>\n"); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + function redirect($url) { | ||
| 104 | + foreach ($_SESSION['KTErrorMessage'] as $sErrorMessage) { | ||
| 105 | + print '<div class="ktError">' . $sErrorMessage . '</div>' . "\n"; | ||
| 106 | + } | ||
| 107 | + printf('Go <a href="%s">here</a> to continue', $url); | ||
| 108 | + printf("</div></div>\n"); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + function end() { | ||
| 112 | + printf("\n--%s--\n", $this->boundary); | ||
| 113 | + } | ||
| 114 | +} |