| 1 | <?php |
|---|
| 2 | /****************************** |
|---|
| 3 | * Class livediagram |
|---|
| 4 | * Michael Fields |
|---|
| 5 | * 11.08.2006 |
|---|
| 6 | * |
|---|
| 7 | * Version 0.1 |
|---|
| 8 | * This Class is for adding live diagrams |
|---|
| 9 | ******************************/ |
|---|
| 10 | |
|---|
| 11 | class livediagram extends extension_base { |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | var $menu = array(); |
|---|
| 15 | |
|---|
| 16 | function main() { |
|---|
| 17 | $content = ""; |
|---|
| 18 | $this->menu['page']['livediagram']['name'] = $this->CLASS['language']->get['ext']['livediagram']['menunewlivediagram']; |
|---|
| 19 | $this->menu['page']['livediagram']['link'] = "index.php?action=new_livediagram"; |
|---|
| 20 | $this->menu['page']['livediagram']['pagerights'] = "2"; |
|---|
| 21 | |
|---|
| 22 | // add menu items to content menu |
|---|
| 23 | $this->menu['content']['editlivediagram']['name'] = $this->CLASS['language']->get['ext']['livediagram']['menueditlivediagram']; |
|---|
| 24 | $this->menu['content']['editlivediagram']['link'] = 'index.php?action=edit_livediagram&peid={$ID}'; |
|---|
| 25 | $this->menu['content']['editlivediagram']['contenttype'] = "livediagram"; |
|---|
| 26 | $this->menu['content']['editlivediagram']['contentrights'] = "2"; |
|---|
| 27 | $this->menu['content']['editlivediagram']['priority'] = "1"; |
|---|
| 28 | |
|---|
| 29 | $this->menu['content']['editlivediagramrights']['name'] = $this->CLASS['language']->get['ext']['livediagram']['menueditlivediagramrights']; |
|---|
| 30 | $this->menu['content']['editlivediagramrights']['link'] = 'index.php?action=edit_livediagram_rights&peid={$ID}'; |
|---|
| 31 | $this->menu['content']['editlivediagramrights']['contenttype'] = "livediagram"; |
|---|
| 32 | $this->menu['content']['editlivediagramrights']['contentrights'] = "2"; |
|---|
| 33 | $this->menu['content']['editlivediagramrights']['login'] = "1"; |
|---|
| 34 | $this->menu['content']['editlivediagramrights']['priority'] = "5"; |
|---|
| 35 | |
|---|
| 36 | $this->menu['content']['deletelivediagram']['name'] = $this->CLASS['language']->get['ext']['livediagram']['menudeletelivediagram']; |
|---|
| 37 | $this->menu['content']['deletelivediagram']['link'] = 'index.php?action=delete_livediagram&pdelid={$ID}'; |
|---|
| 38 | $this->menu['content']['deletelivediagram']['contenttype'] = "livediagram"; |
|---|
| 39 | $this->menu['content']['deletelivediagram']['atagparams'] = "onclick=\"return confirm('" . ((isset($this->CLASS['language']->get['ext']['livediagram']['delete'])) ? $this->CLASS['language']->get['ext']['livediagram']['delete'] : 'delete?') . "');\""; |
|---|
| 40 | $this->menu['content']['deletelivediagram']['contentrights'] = "2"; |
|---|
| 41 | $this->menu['content']['deletelivediagram']['priority'] = "20"; |
|---|
| 42 | |
|---|
| 43 | $this->menu['content']['movelivediagram']['name'] = $this->CLASS['language']->get['ext']['livediagram']['menumovelivediagram']; |
|---|
| 44 | $this->menu['content']['movelivediagram']['link'] = 'index.php?action=move_livediagram&id={$ID}'; |
|---|
| 45 | $this->menu['content']['movelivediagram']['contenttype'] = "livediagram"; |
|---|
| 46 | $this->menu['content']['movelivediagram']['atagparams'] = ""; |
|---|
| 47 | $this->menu['content']['movelivediagram']['contentrights'] = "2"; |
|---|
| 48 | $this->menu['content']['movelivediagram']['priority'] = "10"; |
|---|
| 49 | |
|---|
| 50 | // check if livediagram form is sent |
|---|
| 51 | if(isset($_POST['newdiagramsubmit']) && $_POST['newdiagramsubmit'] != "") { |
|---|
| 52 | $content = $this->new_livediagram_content(); |
|---|
| 53 | } else if (isset($_POST['diagramcontentrights']) && $_POST['diagramcontentrights'] != "") { |
|---|
| 54 | $this->edit_livediagram_contentrights(); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | // check if new livediagram form should be shown |
|---|
| 58 | if(isset($_GET['action']) && $_GET['action'] == "new_livediagram") { |
|---|
| 59 | $content = $this->shownewcontentnameform(); |
|---|
| 60 | } else if (isset($_GET['action']) && $_GET['action'] == "edit_livediagram" && isset($_GET['peid']) && $_GET['peid'] != "") { |
|---|
| 61 | $content = $this->edit_livediagram_content($_GET['peid']); |
|---|
| 62 | } else if (isset($_GET['action']) && $_GET['action'] == "edit_livediagram_rights") { |
|---|
| 63 | $content = $this->showcontentrightsform(); |
|---|
| 64 | } else if (isset($_GET['action']) && $_GET['action'] == "delete_livediagram") { |
|---|
| 65 | $this->delete_livediagram_content(); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | return $content; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | function shownewcontentnameform() { |
|---|
| 72 | if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2) { |
|---|
| 73 | |
|---|
| 74 | $out = ""; |
|---|
| 75 | $name =""; |
|---|
| 76 | |
|---|
| 77 | if(isset($_POST['newdiagramsubmit']) && $_POST['newdiagramsubmit'] != "") { |
|---|
| 78 | $name = $_POST['name']; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | $out .= ' |
|---|
| 82 | <div class="newdiagramform"> |
|---|
| 83 | <fieldset> |
|---|
| 84 | <legend>' . $this->CLASS['language']->get['ext']['livediagram']['menunewlivediagram'] . '</legend> |
|---|
| 85 | |
|---|
| 86 | <form action="index.php" method="post"> |
|---|
| 87 | <div class="nameprompt"> |
|---|
| 88 | ' . $this->CLASS['language']->get['ext']['livediagram']['nameprompt'] . ' |
|---|
| 89 | </div> |
|---|
| 90 | |
|---|
| 91 | <table class="livediagramform" border="0" cellspacing="0" cellpadding="0" width="300"> |
|---|
| 92 | <tr><td><input type="text" name="name" value="' . $name . '" size="25"></td></tr> |
|---|
| 93 | <tr><td> </td></tr>'; |
|---|
| 94 | |
|---|
| 95 | //rights editing panel |
|---|
| 96 | if(!empty($_SESSION['userid'])) { |
|---|
| 97 | $out .= ' <tr><td>' . $this->CLASS['language']->get['ext']['livediagram']['rightsprompt'] . '<br />'; |
|---|
| 98 | $out .= $this->CLASS['knowledgeroot']->rightpanel($_SESSION['userid']); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | $out .= ' </td></tr> <tr><td> <input type="hidden" name="belongsto" value="'. $_SESSION['cid'] . '"></td></tr> |
|---|
| 102 | <tr><td><input class="button" type="submit" name="newdiagramsubmit" value="' . $this->CLASS['language']->get['ext']['livediagram']['buttoncontinue'] . '"> |
|---|
| 103 | <input class="button" type="submit" name="cancel" value="' . $this->CLASS['language']->get['ext']['livediagram']['buttoncancel'] . '"></td></tr> |
|---|
| 104 | </table> |
|---|
| 105 | |
|---|
| 106 | </form> |
|---|
| 107 | </fieldset> |
|---|
| 108 | </div> |
|---|
| 109 | '; |
|---|
| 110 | return $out; |
|---|
| 111 | } |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | function showcontentrightsform() { |
|---|
| 115 | |
|---|
| 116 | if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2) { |
|---|
| 117 | $res = $this->CLASS['db']->query(sprintf("SELECT * FROM content WHERE id=%d",$_GET['peid'])); |
|---|
| 118 | $anz = $this->CLASS['db']->num_rows($res); |
|---|
| 119 | if($anz == 1) { |
|---|
| 120 | $row = $this->CLASS['db']->fetch_assoc($res); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | $out = ' |
|---|
| 124 | <div class="newdiagramform"> |
|---|
| 125 | <fieldset> |
|---|
| 126 | <legend>' . $this->CLASS['language']->get['ext']['livediagram']['menueditlivediagramrights'] . '</legend> |
|---|
| 127 | |
|---|
| 128 | <form action="index.php" method="post"> |
|---|
| 129 | <div class="rightsprompt"> |
|---|
| 130 | ' . $this->CLASS['language']->get['ext']['livediagram']['rightsprompt'] . ' |
|---|
| 131 | </div> |
|---|
| 132 | |
|---|
| 133 | <table class="livediagramform" border="0" cellspacing="0" cellpadding="0" width="300"><tr><td>'; |
|---|
| 134 | |
|---|
| 135 | //rights editing panel |
|---|
| 136 | if(!empty($_SESSION['userid'])) { |
|---|
| 137 | $out .= $this->CLASS['knowledgeroot']->editRightPanel($row['owner'],$row['group'],$row['userrights'].$row['grouprights'].$row['otherrights']); |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | $out .= ' </td></tr> |
|---|
| 141 | <tr><td> <input type="hidden" name="editid" value="' .$_GET['peid']. '"><input type="hidden" name="belongsto" value="'. $_SESSION['cid'] . '"></td></tr> |
|---|
| 142 | <tr><td><input class="button" type="submit" name="diagramcontentrights" value="' . $this->CLASS['language']->get['ext']['livediagram']['buttonsaverights'] . '"> |
|---|
| 143 | <input class="button" type="submit" name="cancel" value="' . $this->CLASS['language']->get['ext']['livediagram']['buttoncancel'] . '"></td></tr> |
|---|
| 144 | </table> |
|---|
| 145 | |
|---|
| 146 | </form> |
|---|
| 147 | </fieldset> |
|---|
| 148 | </div>'; |
|---|
| 149 | |
|---|
| 150 | return $out; |
|---|
| 151 | } |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | function new_livediagram_content() { |
|---|
| 155 | if($this->CLASS['knowledgeroot']->getPageRights($_POST['belongsto'],$_SESSION['userid']) == 2) { |
|---|
| 156 | if(!isset($_POST['close']) || (isset($_POST['close']) && $_POST['close'] == "")) { |
|---|
| 157 | $content = $_POST['name']; |
|---|
| 158 | |
|---|
| 159 | // check server files against name |
|---|
| 160 | $baseCheckPath = $this->getServerBasePath() . "Image/"; |
|---|
| 161 | |
|---|
| 162 | // Initializes the counter used to rename the file, if another one with the same name already exists. |
|---|
| 163 | $iCounter = 0 ; |
|---|
| 164 | $tmpFileName = $content; |
|---|
| 165 | |
|---|
| 166 | while ( true ) |
|---|
| 167 | { |
|---|
| 168 | // Compose the file path. |
|---|
| 169 | $sFilePath = $baseCheckPath . $tmpFileName . ".gif"; |
|---|
| 170 | |
|---|
| 171 | // If a file with that name already exists. |
|---|
| 172 | if ( is_file( $sFilePath ) ) |
|---|
| 173 | { |
|---|
| 174 | $iCounter++ ; |
|---|
| 175 | $tmpFileName = $content . '(' . $iCounter . ')'; |
|---|
| 176 | } |
|---|
| 177 | else |
|---|
| 178 | { |
|---|
| 179 | break ; |
|---|
| 180 | } |
|---|
| 181 | } |
|---|
| 182 | if ($iCounter > 0) { |
|---|
| 183 | $content = $tmpFileName; |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | // get next sorting value |
|---|
| 187 | $res = $this->CLASS['db']->query(sprintf("SELECT max(sorting) as sorting FROM content WHERE belongs_to=%d",$_POST['belongsto'])); |
|---|
| 188 | $sort = $this->CLASS['db']->fetch_assoc($res); |
|---|
| 189 | |
|---|
| 190 | $sorting = $sort['sorting'] + 1; |
|---|
| 191 | |
|---|
| 192 | $content_type = "livediagram"; |
|---|
| 193 | |
|---|
| 194 | if(isset($_SESSION['rightedit']) && $_SESSION['rightedit'] == 1) { |
|---|
| 195 | if($this->CLASS['db']->dbtype == "pgsql") { |
|---|
| 196 | $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content,type,owner,\"group\",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$sorting,$content,$content_type,$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'])); |
|---|
| 197 | } else { |
|---|
| 198 | $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, type, owner,`group`,userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, %d, %d, %d, %d",$_POST['belongsto'],$sorting,$content,$content_type,$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'])); |
|---|
| 199 | } |
|---|
| 200 | } else { |
|---|
| 201 | if(!empty($_SESSION['userid'])) { |
|---|
| 202 | // user logged in but have no rightedit -> use defaultrights |
|---|
| 203 | $res = $this->CLASS['db']->query(sprintf("SELECT id,defaultgroup,defaultrights FROM users WHERE id=%d",$_SESSION['userid'])); |
|---|
| 204 | $anz = $this->CLASS['db']->num_rows($res); |
|---|
| 205 | |
|---|
| 206 | if($anz == 1) { |
|---|
| 207 | $row = $this->CLASS['db']->fetch_assoc($res); |
|---|
| 208 | if($this->CLASS['db']->dbtype == "pgsql") { |
|---|
| 209 | $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, type, owner,\"group\",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$sorting,$content,$content_type,$row['id'],$row['defaultgroup'],substr($row['defaultrights'],0,1),substr($row['defaultrights'],1,1),substr($row['defaultrights'],2,1))); |
|---|
| 210 | } else { |
|---|
| 211 | $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, type, owner,`group`,userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$sorting,$content,$content_type,$row['id'],$row['defaultgroup'],substr($row['defaultrights'],0,1),substr($row['defaultrights'],1,1),substr($row['defaultrights'],2,1))); |
|---|
| 212 | } |
|---|
| 213 | } else { |
|---|
| 214 | if($this->CLASS['db']->dbtype == "pgsql") { |
|---|
| 215 | $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, type, owner,\"group\",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', '0', '0', '2', '2', '2')",$_POST['belongsto'],$sorting,$content,$content_type)); |
|---|
| 216 | } else { |
|---|
| 217 | $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, type, owner,`group`,userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', '0', '0', '2', '2', '2')",$_POST['belongsto'],$sorting,$content,$content_type)); |
|---|
| 218 | } |
|---|
| 219 | } |
|---|
| 220 | } else { |
|---|
| 221 | // no user logged in |
|---|
| 222 | if($this->CLASS['db']->dbtype == "pgsql") { |
|---|
| 223 | $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, type, owner,\"group\",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', '0', '0', '2', '2', '2')",$_POST['belongsto'],$sorting,$content,$content_type)); |
|---|
| 224 | } else { |
|---|
| 225 | $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, type, owner,`group`,userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', '0', '0', '2', '2', '2')",$_POST['belongsto'],$sorting,$content,$content_type)); |
|---|
| 226 | } |
|---|
| 227 | } |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | if($res) { |
|---|
| 231 | //$this->CLASS['kr_header']->addmessage("Live Diagram content created"); |
|---|
| 232 | } else { |
|---|
| 233 | $this->CLASS['kr_header']->addwarning($this->CLASS['language']->get['ext']['livediagram']['errorcreatefailed']); |
|---|
| 234 | } |
|---|
| 235 | |
|---|
| 236 | if($_POST['newdiagramsubmit'] != "") { |
|---|
| 237 | $newid = $this->CLASS['db']->last_id("seq_knowledge"); |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | $pagename = $this->CLASS['path']->getTreePageTitle($_POST['belongsto']); |
|---|
| 241 | |
|---|
| 242 | return $this->edit_livediagram_content($newid); |
|---|
| 243 | // email notification |
|---|
| 244 | $this->CLASS['notification']->send_email_notification($_POST['belongsto'],"content","created",$pagename, $newid); |
|---|
| 245 | } |
|---|
| 246 | } |
|---|
| 247 | } |
|---|
| 248 | |
|---|
| 249 | function edit_livediagram_contentrights() { |
|---|
| 250 | if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2 && $this->CLASS['knowledgeroot']->getContentRights($_POST['editid'],$_SESSION['userid']) == 2) { |
|---|
| 251 | if($_POST['close'] == "") { |
|---|
| 252 | if($_SESSION['rightedit'] == 1) { |
|---|
| 253 | if($this->CLASS['db']->dbtype == "pgsql") { |
|---|
| 254 | $res = $this->CLASS['db']->query(sprintf("UPDATE content SET owner=%d, \"group\"=%d, userrights=%d, grouprights=%d, otherrights=%d WHERE id=%d",$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'],$_POST['editid'])); |
|---|
| 255 | } else { |
|---|
| 256 | $res = $this->CLASS['db']->query(sprintf("UPDATE content SET owner=%d, `group`=%d, userrights=%d, grouprights=%d, otherrights=%d WHERE id=%d",$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'],$_POST['editid'])); |
|---|
| 257 | } |
|---|
| 258 | } else { |
|---|
| 259 | $this->CLASS['kr_header']->addwarning($this->CLASS['language']->get['ext']['livediagram']['errorinsufficientrights']); |
|---|
| 260 | } |
|---|
| 261 | } |
|---|
| 262 | } |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | // delete content |
|---|
| 267 | function delete_livediagram_content() { |
|---|
| 268 | if($this->CLASS['knowledgeroot']->getContentRights($_GET['pdelid'],$_SESSION['userid']) == 2) { |
|---|
| 269 | $res = $this->CLASS['db']->query(sprintf("UPDATE content SET deleted=1 WHERE id=%d",$_GET['pdelid'])); |
|---|
| 270 | $res = $this->CLASS['db']->query(sprintf("UPDATE files SET deleted=1 WHERE belongs_to=%d",$_GET['pdelid'])); |
|---|
| 271 | |
|---|
| 272 | // get id of page |
|---|
| 273 | $res = $this->CLASS['db']->query(sprintf("SELECT belongs_to FROM content WHERE id=%d",$_GET['pdelid'])); |
|---|
| 274 | $anz = $this->CLASS['db']->num_rows($res); |
|---|
| 275 | |
|---|
| 276 | if($anz == 1) { |
|---|
| 277 | $row = $this->CLASS['db']->fetch_assoc($res); |
|---|
| 278 | $pagename = $this->CLASS['path']->getTreePageTitle($row['belongs_to']); |
|---|
| 279 | $pageid = $row['belongs_to']; |
|---|
| 280 | } else { |
|---|
| 281 | $pagename = $this->CLASS['path']->getTreePageTitle($_SESSION['cid']); |
|---|
| 282 | $pageid = $_SESSION['cid']; |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | // TODO delete generated files |
|---|
| 286 | |
|---|
| 287 | // email notification |
|---|
| 288 | $this->CLASS['notification']->send_email_notification($pageid,"content","deleted",$pagename,$_GET['pdelid']); |
|---|
| 289 | } |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | function edit_livediagram_content($id) { |
|---|
| 293 | if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2 && $this->CLASS['knowledgeroot']->getContentRights($id,$_SESSION['userid']) == 2) { |
|---|
| 294 | $res = $this->CLASS['db']->query(sprintf("SELECT * FROM content WHERE id=%d",$id)); |
|---|
| 295 | $anz = $this->CLASS['db']->num_rows($res); |
|---|
| 296 | if($anz == 1) { |
|---|
| 297 | $row = $this->CLASS['db']->fetch_assoc($res); |
|---|
| 298 | $diagramname = $row['content']; |
|---|
| 299 | |
|---|
| 300 | // compute knowledgeroot and upload directory locations |
|---|
| 301 | $serverBasePath = $this->getBasePath(); |
|---|
| 302 | $userFilesPath = $serverBasePath . $this->CLASS['vars']['knowledgeroot']['uploadfolder'] ; |
|---|
| 303 | $sessionParam = ""; |
|---|
| 304 | if (strlen(session_name()) > 0) |
|---|
| 305 | $sessionParam = "?" . session_name() . "=" . session_id(); |
|---|
| 306 | |
|---|
| 307 | $out = ""; |
|---|
| 308 | if (isset($_POST['newdiagramsubmit']) && $_POST['newdiagramsubmit'] == "") { |
|---|
| 309 | $out .= " <img src=\"" . $userFilesPath . "Image/$diagramname.gif\" border=\"2\" title=\"$diagramname\" alt=\"Image of diagram $diagramname\" usemap=\"#$diagramname\"/>"; |
|---|
| 310 | } |
|---|
| 311 | $out .= " |
|---|
| 312 | <br /><br /><applet code=\"de.knowledgeroot.LiveDiagram.class\" archive=\"" . $serverBasePath . "system/extension/livediagram/livediagram.jar\" width=\"100%\" height=\"40\">"; |
|---|
| 313 | $out .= " <param name=\"drawpath\" value=\"" . $userFilesPath . "Livediagrams/$diagramname.draw\" />"; |
|---|
| 314 | $out .= "<param name=\"gifpath\" value=\"" . $userFilesPath . "Image/$diagramname.gif\" /> |
|---|
| 315 | <param name=\"extracolors\" value=\"Aquamarine=#70DB93,Flesh=#EBC79E,Sea Green=#238E68\" /> |
|---|
| 316 | <param name=\"savepath\" value=\"" . $serverBasePath . "system/extension/livediagram/livediagram-upload.php\" /> |
|---|
| 317 | <param name=\"viewpath\" value=\"" . $serverBasePath . "index.php$sessionParam\" /> |
|---|
| 318 | <param name=\"helppath\" value=\"" . $serverBasePath . "index.php\" /> |
|---|
| 319 | </applet> "; |
|---|
| 320 | |
|---|
| 321 | return $out; |
|---|
| 322 | } |
|---|
| 323 | } |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | function show_content($id) { |
|---|
| 327 | $res = $this->CLASS['db']->query(sprintf("SELECT * FROM content WHERE id=%d",$id)); |
|---|
| 328 | $anz = $this->CLASS['db']->num_rows($res); |
|---|
| 329 | if($anz == 1) { |
|---|
| 330 | $row = $this->CLASS['db']->fetch_assoc($res); |
|---|
| 331 | $diagramname = $row['content']; |
|---|
| 332 | $imageMapData = $this->get_include_contents($this->getServerBasePath() . "Livediagrams/$diagramname.map"); |
|---|
| 333 | $useMapString = !empty($imageMapData) ? "usemap=\"#$diagramname\"" : ""; |
|---|
| 334 | |
|---|
| 335 | $out = " <img src=\"" . $this->getUserFilesPath() . "Image/$diagramname.gif\" border=\"2\" title=\"$diagramname\" alt=\"Image of diagram $diagramname\" $useMapString/>"; |
|---|
| 336 | // output image map file |
|---|
| 337 | $out .= $imageMapData; |
|---|
| 338 | |
|---|
| 339 | return $out; |
|---|
| 340 | } |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | function getBasePath() { |
|---|
| 344 | $serverBasePath = $_SERVER['PHP_SELF'] ; |
|---|
| 345 | $serverBasePath = substr( $serverBasePath, 0, strpos( $serverBasePath, "index.php" ) ); |
|---|
| 346 | return $serverBasePath; |
|---|
| 347 | } |
|---|
| 348 | |
|---|
| 349 | function getUserFilesPath() { |
|---|
| 350 | return $userFilesPath = $this->getBasePath() . $this->CLASS['vars']['knowledgeroot']['uploadfolder'] ; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | function getServerBasePath() { |
|---|
| 354 | /* |
|---|
| 355 | if ($this->CLASS['vars']['knowledgeroot']['uploadserverpath'] == "auto") { |
|---|
| 356 | $dir = substr( dirname(__FILE__), 0, strpos( dirname(__FILE__), "system" ) ); |
|---|
| 357 | $userFilesServerPath = $dir . "/" . $this->CLASS['vars']['knowledgeroot']['uploadfolder']; |
|---|
| 358 | } else { |
|---|
| 359 | $userFilesServerPath = $this->CLASS['vars']['knowledgeroot']['uploadserverpath']; |
|---|
| 360 | } |
|---|
| 361 | return $userFilesServerPath; |
|---|
| 362 | */ |
|---|
| 363 | return $this->CLASS['vars']['base_path']; |
|---|
| 364 | } |
|---|
| 365 | function get_include_contents($filename) { |
|---|
| 366 | if (is_file($filename)) { |
|---|
| 367 | ob_start(); |
|---|
| 368 | include $filename; |
|---|
| 369 | $contents = ob_get_contents(); |
|---|
| 370 | ob_end_clean(); |
|---|
| 371 | |
|---|
| 372 | return $contents; |
|---|
| 373 | } else { |
|---|
| 374 | // error_log($filename . " Is not a valid file"); |
|---|
| 375 | } |
|---|
| 376 | return ""; |
|---|
| 377 | } |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | ?> |
|---|