-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
documents.php
225 lines (183 loc) · 6.2 KB
/
documents.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
require_once SEEDROOT."DocRep/DocRepUI.php";
class CATSDocApp extends DocRepApp1
{
private $oApp;
private $oDocRepDB;
private $oDocRepUI;
function __construct( SEEDAppSessionAccount $oApp, $kSelectedDoc, DocRepDB2 $oDB, CATSDocRepUI $oUI )
{
parent::__construct( $oUI, $oDB, $kSelectedDoc );
$this->oApp = $oApp;
}
function Edit0()
{
$s = "";
$s = "PUT THE EDIT FORM HERE";
return( $s );
}
function Rename0()
{
$s = "";
if( ($k = $this->GetSelectedDocKey()) ) {
$oForm = new SEEDCoreForm( 'Plain' );
$s .= "<form method='post'>"
.$oForm->Hidden( 'k', array( 'value' => $k ) ) // so the UI knows the current doc in the tree
.$oForm->Hidden( 'action', array( 'value' => 'rename2' ) )
.$oForm->Text( 'doc_name', '' ) // the new document name
."<input type='submit' value='Rename'/>"
."</form>";
}
return( $s );
}
}
class CATSDocRepUI extends DocRepUI
{
function __construct( DocRepDB2 $oDocRepDB )
{
parent::__construct( $oDocRepDB );
}
function DrawTree_title( DocRepDoc2 $oDoc, $raTitleParms )
/*********************************************************
This is called from DocRepUI::DrawTree for every item in the tree. It writes the content of <div class='DocRepTree_title'>.
raTitleParms:
bSelectedDoc: true if this document is selected in the tree and should be highlighted
sExpandCmd: the command to be issued if the user clicks on a tree-expand-collapse control associated with this item
*/
{
$kDoc = $oDoc->GetKey();
$s = "<a href='${_SERVER['PHP_SELF']}?k=$kDoc'><nobr>"
.( $raTitleParms['bSelectedDoc'] ? "<span class='cats_doctree_titleSelected'>" : "" )
.($oDoc->GetTitle('') ?: ($oDoc->GetName() ?: "Untitled"))
.( $raTitleParms['bSelectedDoc'] ? "</span>" : "" )
."</nobr></a>";
return( $s );
}
}
class CATSDocumentManager
{
private $oApp;
public $oDocMan;
function __construct( SEEDAppSessionAccount $oApp, $kSelectedDoc )
{
$this->oApp = $oApp;
$oDocRepDB = new DocRepDB2( $oApp->kfdb, $oApp->sess->GetUID(), array( 'raPermClassesR'=>array(1), 'logdir'=>CATSDIR_LOG ) );
$oDocRepUI = new CATSDocRepUI( $oDocRepDB );
$this->oDocMan = new CATSDocApp( $oApp, $kSelectedDoc, $oDocRepDB, $oDocRepUI );
}
function DrawMainTabs()
{
return( "" );
}
function DrawTreeTabs()
{
$s = $this->oDocMan->TreeTabs();
return( $s );
$s = "<div class='row'>"
.$this->tab( "View", "view0" )
.$this->tab( "Edit", "edit0" )
.$this->tab( "Rename", "rename0" )
//.$this->tab( "Tell a Joke", "joke0" )
."</div>";
return( $s );
}
private function tab( $label, $tabcmd )
{
return( "<div class='col-md-2'>"
."<a href='{$_SERVER['PHP_SELF']}?tab=$tabcmd&k=".$this->oDocMan->GetSelectedDocKey()."'>$label</a>"
."</div>" );
/*
."<form method='post'>"
."<input type='hidden' name='k' value='".$this->oDocMan->GetSelectedDocKey()."'/>"
."<input type='hidden' name='action' value='$action'/>"
."<input type='submit' value='$label'/>"
."</form></div>" );
*/
}
function Style()
{
return( $this->oDocMan->Style()."
<style>
.DocRepTree_level { margin-left:30px; }
.cats_docmaintabs {
margin: 30px 0 -20px 30px;
}
.cats_doctree {
border:1px solid #888;
background-color:#ddd;
border-radius:10px;
margin:20px;
padding:20px;
}
.cats_doctreetabs {
margin-bottom:10px;
}
.cats_doctree_titleSelected {
font-weight: bold;
}
.cats_docpreview_folder {
}
.cats_docform {
background-color:#eee;
border:1px solid #777;
border-radius: 10px;
padding:20px;
}
</style>
" );
}
}
function DocumentManager( SEEDAppSessionAccount $oApp )
{
$s = "";
$kSelectedDoc = SEEDInput_Int('k');
$o = new CATSDocumentManager( $oApp, $kSelectedDoc );
$s .= $o->Style();
// default "action" is to show the PreviewDoc
$sRight = $sRightClass = "";
switch( ($pTab = $oApp->sess->SmartGPC( 'tab' )) ) {
case "rename0":
//$sRight = $o->oDocMan->Rename0();
//$sRightClass = "cats_docform";
break;
case "edit0":
//$sRight = $o->oDocMan->Edit0();
//$sRightClass = "cats_docform";
break;
case "joke0":
//$sRight = "Did you hear the one about the cat who needed OT? He got therapurr.";
//$sRightClass = "cats_docform";
break;
default:
if( $o->oDocMan->oDoc ) {
switch( $o->oDocMan->oDoc->GetType() ) {
case 'FOLDER':
//$sRightClass= 'cats_docpreview_doc';
break;
case 'DOC':
//$sRight = $o->oDocMan->PreviewDoc();
//$sRightClass = "cats_docpreview_doc";
break;
case 'IMAGE':
break;
case 'WHATEVER':
break;
}
}
break;
}
$s .= "<div class='cats_docmaintabs'><div class='container-fluid'>".$o->DrawMainTabs()."</div></div>";
$s .= "<div class='cats_doctree'>"
."<div class='container-fluid'>"
."<div class='row'>"
."<div class='col-md-6'>".$o->oDocMan->DrawDocTree( 0 )."</div>"
."<div class='col-md-6'>"
.($o->oDocMan->GetSelectedDocKey() ? ("<div class='cats_doctreetabs'>".$o->DrawTreeTabs()."</div>") : "")
."<div class='cats_docform'>".$o->oDocMan->TreeForms()."</div>"
."</div>"
."</div>"
."</div></div>";
$s = str_replace( "[[DocRepApp_TreeForm_View_Text]]", $o->oDocMan->GetDocHTML(), $s );
return( $s );
}
?>