mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-11-27 18:10:42 +00:00
add javascript based editor (only bootstrap4 theme)
This commit is contained in:
parent
d8812eebd7
commit
6b40e9103a
100
out/out.EditMarkdown.php
Normal file
100
out/out.EditMarkdown.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
// MyDMS. Document Management System
|
||||
// Copyright (C) 2002-2005 Markus Westphal
|
||||
// Copyright (C) 2006-2008 Malcolm Cowe
|
||||
// Copyright (C) 2010-2016 Uwe Steinmann
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
if(!isset($settings))
|
||||
require_once("../inc/inc.Settings.php");
|
||||
require_once("inc/inc.Utils.php");
|
||||
require_once("inc/inc.LogInit.php");
|
||||
require_once("inc/inc.Language.php");
|
||||
require_once("inc/inc.Init.php");
|
||||
require_once("inc/inc.Extension.php");
|
||||
require_once("inc/inc.DBInit.php");
|
||||
require_once("inc/inc.ClassUI.php");
|
||||
require_once("inc/inc.Authentication.php");
|
||||
|
||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||
|
||||
$documentid = $_GET["documentid"];
|
||||
if (!isset($documentid) || !is_numeric($documentid) || intval($documentid)<1) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||
}
|
||||
|
||||
$document = $dms->getDocument($documentid);
|
||||
|
||||
if (!is_object($document)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||
}
|
||||
|
||||
if ($document->getAccessMode($user) < M_READWRITE) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
||||
}
|
||||
|
||||
if(isset($_GET["version"])) {
|
||||
$version = $_GET["version"];
|
||||
|
||||
if (!is_numeric($version)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
$content = $document->getContentByVersion($version);
|
||||
$lc = $document->getLatestContent();
|
||||
|
||||
} else {
|
||||
$version = 0;
|
||||
$content = $document->getLatestContent();
|
||||
$lc = $document->getLatestContent();
|
||||
}
|
||||
|
||||
if (!is_object($content)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
/* Only the latest version may be edited */
|
||||
if($content->getVersion() != $lc->getVersion()) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
/*
|
||||
if (!isset($settings->_editOnlineFileTypes) || !is_array($settings->_editOnlineFileTypes) || !in_array(strtolower($content->getFileType()), $settings->_editOnlineFileTypes)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
*/
|
||||
|
||||
/* Create object for checking access to certain operations */
|
||||
$accessop = new SeedDMS_AccessOperation($dms, $document, $user, $settings);
|
||||
if(!$accessop->mayEditVersion($version)) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
||||
}
|
||||
|
||||
$folder = $document->getFolder();
|
||||
|
||||
if($view) {
|
||||
$view->setParam('document', $document);
|
||||
$view->setParam('version', $content);
|
||||
$view->setParam('folder', $folder);
|
||||
$view->setParam('accessobject', $accessop);
|
||||
$view->setParam('cachedir', $settings->_cacheDir);
|
||||
$view->setParam('previewWidthList', $settings->_previewWidthList);
|
||||
$view->setParam('previewWidthDetail', $settings->_previewWidthDetail);
|
||||
$view->setParam('timeout', $settings->_cmdTimeout);
|
||||
$view($_GET);
|
||||
exit;
|
||||
}
|
||||
122
views/bootstrap/class.EditMarkdown.php
Normal file
122
views/bootstrap/class.EditMarkdown.php
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
/**
|
||||
* Implementation of EditOnline view
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @license GPL 2
|
||||
* @version @version@
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
||||
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
||||
* 2010-2012 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include parent class
|
||||
*/
|
||||
//require_once("class.Bootstrap.php");
|
||||
|
||||
/**
|
||||
* Class which outputs the html page for EditOnline view
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
||||
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
||||
* 2010-2012 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_View_EditMarkdown extends SeedDMS_Theme_Style {
|
||||
var $dms;
|
||||
var $folder_count;
|
||||
var $document_count;
|
||||
var $file_count;
|
||||
var $storage_size;
|
||||
|
||||
function js() { /* {{{ */
|
||||
$document = $this->params['document'];
|
||||
header('Content-Type: application/javascript; charset=UTF-8');
|
||||
?>
|
||||
var editor;
|
||||
$(function() {
|
||||
editor = editormd("editor", {
|
||||
// width: "100%",
|
||||
height: 560,
|
||||
// markdown: "xxxx", // dynamic set Markdown text
|
||||
path : "/views/bootstrap4/vendors/editor.md/lib/" // Autoload modules mode, codemirror, marked... dependents libs path
|
||||
});
|
||||
});
|
||||
$(document).ready(function() {
|
||||
$('#update').click(function(event) {
|
||||
event.preventDefault();
|
||||
// alert(editor.getMarkdown());
|
||||
$.post("../op/op.EditOnline.php", $('#form1').serialize(), function(response) {
|
||||
noty({
|
||||
text: response.message,
|
||||
type: response.success === true ? 'success' : 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 1500,
|
||||
});
|
||||
}, "json");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
<?php
|
||||
} /* }}} */
|
||||
|
||||
function show() { /* {{{ */
|
||||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$document = $this->params['document'];
|
||||
$version = $this->params['version'];
|
||||
$cachedir = $this->params['cachedir'];
|
||||
$previewwidthlist = $this->params['previewWidthList'];
|
||||
$previewwidthdetail = $this->params['previewWidthDetail'];
|
||||
|
||||
$set = 'markdown'; //default or markdown
|
||||
$skin = 'simple'; // simple or markitup
|
||||
$this->htmlAddHeader('<link href="'.$this->params['settings']->_httpRoot.'views/'.$this->theme.'/vendors/editor.md/css/editormd.min.css" rel="stylesheet"/>');
|
||||
$this->htmlAddHeader('<script type="text/javascript" src="'.$this->params['settings']->_httpRoot.'views/'.$this->theme.'/vendors/editor.md/editormd.min.js"></script>');
|
||||
$this->htmlAddHeader('<script type="text/javascript" src="'.$this->params['settings']->_httpRoot.'views/'.$this->theme.'/vendors/editor.md/languages/en.js"></script>');
|
||||
|
||||
$this->htmlStartPage(getMLText("edit_online"));
|
||||
$this->globalNavigation();
|
||||
$this->contentStart();
|
||||
$folder = $document->getFolder();
|
||||
$this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document", $document);
|
||||
$this->rowStart();
|
||||
$this->columnStart(12);
|
||||
?>
|
||||
<form action="../op/op.EditOnline.php" id="form1" method="post">
|
||||
<input type="hidden" name="documentid" value="<?php echo $document->getId(); ?>" />
|
||||
<div id="editor">
|
||||
<textarea id="markdown" name="data" style="display: nont;">
|
||||
<?php
|
||||
$luser = $document->getLatestContent()->getUser();
|
||||
echo htmlspecialchars(file_get_contents($dms->contentDir . $version->getPath()), ENT_SUBSTITUTE);
|
||||
?>
|
||||
</textarea>
|
||||
</div>
|
||||
<?php
|
||||
if($user->getId() == $luser->getId()) {
|
||||
echo $this->warningMsg(getMLText('edit_online_warning'));
|
||||
$this->formSubmit('<i class="fa fa-save"></i> '.getMLText('save'),'update','','primary');
|
||||
} else {
|
||||
echo $this->errorMsg(getMLText('edit_online_not_allowed'));
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
$this->columnEnd();
|
||||
$this->rowEnd();
|
||||
$this->contentContainerEnd();
|
||||
$this->contentEnd();
|
||||
$this->htmlEndPage();
|
||||
} /* }}} */
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user