replace all ˝\n" by PHP_EOL

This commit is contained in:
Uwe Steinmann 2020-09-04 09:21:40 +02:00
parent 4e3922627b
commit e10ce3dc4b
6 changed files with 115 additions and 126 deletions

View File

@ -8,36 +8,36 @@ if(isset($_SERVER['SEEDDMS_HOME'])) {
}
function usage() { /* {{{ */
echo "Usage:\n";
echo " seeddms-adddoc [--config <file>] [-c <comment>] [-k <keywords>] [-s <number>] [-n <name>] [-V <version>] [-s <sequence>] [-t <mimetype>] [-a <attribute=value>] [-h] [-v] -F <folder id> -D <document id> -f <filename>\n";
echo "\n";
echo "Description:\n";
echo " This program uploads a file into a folder or updates a document of SeedDMS.\n";
echo "\n";
echo "Options:\n";
echo " -h, --help: print usage information and exit.\n";
echo " -v, --version: print version and exit.\n";
echo " --config: set alternative config file.\n";
echo " -F <folder id>: id of folder the file is uploaded to\n";
echo " -D <document id>: id of document the file is uploaded to.\n";
echo " This will only be used if no folder id is given.\n";
echo " -c <comment>: set comment for document. See [1].\n";
echo " -C <comment>: set comment for version\n";
echo " -k <keywords>: set keywords for file. See [1].\n";
echo " -K <categories>: set categories for file. See [1].\n";
echo " -s <number>: set sequence for file (used for ordering files within a folder. See [1].\n";
echo " -n <name>: set name of file\n";
echo " -V <version>: set version of file (defaults to 1). See [2].\n";
echo " -u <user>: login name of user\n";
echo " -f <filename>: upload this file\n";
echo " -s <sequence>: set sequence of file. See [1]\n";
echo " -t <mimetype> set mimetype of file manually. Do not do that unless you know\n";
echo " what you do. If not set, the mimetype will be determined automatically.\n";
echo " -a <attribute=value>: Set a document attribute; can occur multiple times. See [1].\n";
echo " -A <attribute=value>: Set a version attribute; can occur multiple times.\n";
echo "\n";
echo "[1] This option applies only if a new document is uploaded. It has no effect\n"." if a new document version is uploaded.\n";
echo "[2] If a new document version is uploaded it defaults to the next version number.\n";
echo "Usage:".PHP_EOL;
echo " seeddms-adddoc [--config <file>] [-c <comment>] [-k <keywords>] [-s <number>] [-n <name>] [-V <version>] [-s <sequence>] [-t <mimetype>] [-a <attribute=value>] [-h] [-v] -F <folder id> -D <document id> -f <filename>".PHP_EOL;
echo PHP_EOL;
echo "Description:".PHP_EOL;
echo " This program uploads a file into a folder or updates a document of SeedDMS.".PHP_EOL;
echo PHP_EOL;
echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.".PHP_EOL;
echo " --config: set alternative config file.".PHP_EOL;
echo " -F <folder id>: id of folder the file is uploaded to".PHP_EOL;
echo " -D <document id>: id of document the file is uploaded to.".PHP_EOL;
echo " This will only be used if no folder id is given.".PHP_EOL;
echo " -c <comment>: set comment for document. See [1].".PHP_EOL;
echo " -C <comment>: set comment for version".PHP_EOL;
echo " -k <keywords>: set keywords for file. See [1].".PHP_EOL;
echo " -K <categories>: set categories for file. See [1].".PHP_EOL;
echo " -s <number>: set sequence for file (used for ordering files within a folder. See [1].".PHP_EOL;
echo " -n <name>: set name of file".PHP_EOL;
echo " -V <version>: set version of file (defaults to 1). See [2].".PHP_EOL;
echo " -u <user>: login name of user".PHP_EOL;
echo " -f <filename>: upload this file".PHP_EOL;
echo " -s <sequence>: set sequence of file. See [1]".PHP_EOL;
echo " -t <mimetype> set mimetype of file manually. Do not do that unless you know".PHP_EOL;
echo " what you do. If not set, the mimetype will be determined automatically.".PHP_EOL;
echo " -a <attribute=value>: Set a document attribute; can occur multiple times. See [1].".PHP_EOL;
echo " -A <attribute=value>: Set a version attribute; can occur multiple times.".PHP_EOL;
echo PHP_EOL;
echo "[1] This option applies only if a new document is uploaded. It has no effect".PHP_EOL." if a new document version is uploaded.".PHP_EOL;
echo "[2] If a new document version is uploaded it defaults to the next version number.".PHP_EOL;
} /* }}} */
$version = "0.0.1";
@ -56,7 +56,7 @@ if(isset($options['h']) || isset($options['help'])) {
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version."\n";
echo $version.PHP_EOL;
exit(0);
}
@ -75,7 +75,7 @@ if(isset($options['F'])) {
if(isset($options['D'])) {
$documentid = (int) $options['D'];
} else {
echo "Missing folder/document ID\n";
echo "Missing folder/document ID".PHP_EOL;
usage();
exit(1);
}
@ -151,7 +151,7 @@ if(isset($options['K'])) {
if($cat) {
$categories[] = $cat;
} else {
echo "Category '".$categoryname."' not found\n";
echo "Category '".$categoryname."' not found".PHP_EOL;
}
}
} /* }}} */
@ -170,12 +170,12 @@ if (isset($options['a'])) {
$attrKey = strstr($thisAttribute, '=', true);
$attrVal = substr(strstr($thisAttribute, '='), 1);
if (empty($attrKey) || empty($attrVal)) {
echo "Document attribute $thisAttribute not understood\n";
echo "Document attribute $thisAttribute not understood".PHP_EOL;
exit(1);
}
$attrdef = $dms->getAttributeDefinitionByName($attrKey);
if (!$attrdef) {
echo "Document attribute $attrKey unknown\n";
echo "Document attribute $attrKey unknown".PHP_EOL;
exit(1);
}
$document_attributes[$attrdef->getID()] = $attrVal;
@ -196,12 +196,12 @@ if (isset($options['A'])) {
$attrKey = strstr($thisAttribute, '=', true);
$attrVal = substr(strstr($thisAttribute, '='), 1);
if (empty($attrKey) || empty($attrVal)) {
echo "Version attribute $thisAttribute not understood\n";
echo "Version attribute $thisAttribute not understood".PHP_EOL;
exit(1);
}
$attrdef = $dms->getAttributeDefinitionByName($attrKey);
if (!$attrdef) {
echo "Version attribute $attrKey unknown\n";
echo "Version attribute $attrKey unknown".PHP_EOL;
exit(1);
}
$version_attributes[$attrdef->getID()] = $attrVal;
@ -253,11 +253,11 @@ if(is_readable($filename)) {
}
$filetype = "." . pathinfo($filename, PATHINFO_EXTENSION);
} else {
echo "File '".$filename."' has zero size\n";
echo "File '".$filename."' has zero size".PHP_EOL;
exit(1);
}
} else {
echo "File '".$filename."' is not readable\n";
echo "File '".$filename."' is not readable".PHP_EOL;
exit(1);
}
/* }}} */
@ -268,30 +268,30 @@ if($folderid) {
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
echo "Could not find specified folder\n";
echo "Could not find specified folder".PHP_EOL;
exit(1);
}
if ($folder->getAccessMode($user) < M_READWRITE) {
echo "Not sufficient access rights\n";
echo "Not sufficient access rights".PHP_EOL;
exit(1);
}
} elseif($documentid) {
$document = $dms->getDocument($documentid);
if (!is_object($document)) {
echo "Could not find specified document\n";
echo "Could not find specified document".PHP_EOL;
exit(1);
}
if ($document->getAccessMode($user) < M_READWRITE) {
echo "Not sufficient access rights\n";
echo "Not sufficient access rights".PHP_EOL;
exit(1);
}
}
if (!is_numeric($sequence)) {
echo "Sequence must be numeric\n";
echo "Sequence must be numeric".PHP_EOL;
exit(1);
}
@ -346,7 +346,7 @@ if($folder) {
$controller->setParam('defaultaccessdocs', $settings->_defaultAccessDocs);
if(!$document = $controller->run()) {
echo "Could not add document to folder\n";
echo "Could not add document to folder".PHP_EOL;
exit(1);
}
} elseif($document) {
@ -366,7 +366,7 @@ if($folder) {
$controller->setParam('workflow', null);
if(!$content = $controller->run()) {
echo "Could not add version to document\n";
echo "Could not add version to document".PHP_EOL;
exit(1);
}
}

View File

@ -8,21 +8,21 @@ if(isset($_SERVER['SEEDDMS_HOME'])) {
}
function usage() { /* {{{ */
echo "Usage:\n";
echo " seeddms-createfolder [--config <file>] [-c <comment>] [-n <name>] [-s <sequence>] [-h] [-v] -F <parent id>\n";
echo "\n";
echo "Description:\n";
echo " This program creates a new folder in SeedDMS.\n";
echo "\n";
echo "Options:\n";
echo " -h, --help: print usage information and exit.\n";
echo " -v, --version: print version and exit.\n";
echo " --config: set alternative config file.\n";
echo " -u <user>: login name of user\n";
echo " -F <parent id>: id of parent folder\n";
echo " -c <comment>: set comment for file\n";
echo " -n <name>: set name of the folder\n";
echo " -s <sequence>: set sequence of folder\n";
echo "Usage:".PHP_EOL;
echo " seeddms-createfolder [--config <file>] [-c <comment>] [-n <name>] [-s <sequence>] [-h] [-v] -F <parent id>".PHP_EOL;
echo PHP_EOL;
echo "Description:".PHP_EOL;
echo " This program creates a new folder in SeedDMS.".PHP_EOL;
echo PHP_EOL;
echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.".PHP_EOL;
echo " --config: set alternative config file.".PHP_EOL;
echo " -u <user>: login name of user".PHP_EOL;
echo " -F <parent id>: id of parent folder".PHP_EOL;
echo " -c <comment>: set comment for file".PHP_EOL;
echo " -n <name>: set name of the folder".PHP_EOL;
echo " -s <sequence>: set sequence of folder".PHP_EOL;
} /* }}} */
$version = "0.0.1";
@ -41,7 +41,7 @@ if(isset($options['h']) || isset($options['help'])) {
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version."\n";
echo $version.PHP_EOL;
exit(0);
}
@ -55,7 +55,7 @@ if(isset($options['config'])) {
if(isset($options['F'])) {
$folderid = (int) $options['F'];
} else {
echo "Missing parent folder ID\n";
echo "Missing parent folder ID".PHP_EOL;
usage();
exit(1);
}
@ -127,17 +127,17 @@ if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) {
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
echo "Could not find specified folder\n";
echo "Could not find specified folder".PHP_EOL;
exit(1);
}
if ($folder->getAccessMode($user) < M_READWRITE) {
echo "Not sufficient access rights\n";
echo "Not sufficient access rights".PHP_EOL;
exit(1);
}
if (!is_numeric($sequence)) {
echo "Sequence must be numeric\n";
echo "Sequence must be numeric".PHP_EOL;
exit(1);
}
@ -150,7 +150,7 @@ $controller->setParam('attributes', array());
$controller->setParam('notificationgroups', array());
$controller->setParam('notificationusers', array());
if(!$subFolder = $controller->run()) {
echo "Could not add subfolder to folder\n";
echo "Could not add subfolder to folder".PHP_EOL;
} else {
// Send notification to subscribers.
if($notifier) {

View File

@ -10,10 +10,10 @@ if(isset($_SERVER['SEEDDMS_HOME'])) {
function usage() { /* {{{ */
echo "Usage:".PHP_EOL;
echo " seeddms-indexer [-h] [-v] [-c] [--config <file>]".PHP_EOL;
echo "".PHP_EOL;
echo PHP_EOL;
echo "Description:".PHP_EOL;
echo " This program recreates the full text index of SeedDMS.".PHP_EOL;
echo "".PHP_EOL;
echo PHP_EOL;
echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.".PHP_EOL;
@ -37,7 +37,7 @@ if(isset($options['h']) || isset($options['help'])) {
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version."".PHP_EOL;
echo $version.PHP_EOL;
exit(0);
}
@ -86,7 +86,7 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
}
$documents = $folder->getDocuments();
foreach($documents as $document) {
echo $indent." ".$document->getId().":".$document->getName()." ";
echo $themes->black($indent." ".$document->getId().":".$document->getName()." ");
$lucenesearch = new $indexconf['Search']($index);
if(!($hit = $lucenesearch->getDocument($document->getId()))) {
try {
@ -135,23 +135,12 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
$themes = new \AlecRabbit\ConsoleColour\Themes();
$db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
echo "Database update needed.".PHP_EOL;
exit(1);
}
$dms->setRootFolderID($settings->_rootFolderID);
if($recreate)
$index = $indexconf['Indexer']::create($settings->_luceneDir);
else
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if(!$index) {
echo "Could not create index.".PHP_EOL;
echo $themes->error("Could not create index.").PHP_EOL;
exit(1);
}

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash
if [ -z "${SEEDDMS_HOME}" ]; then
echo 'Please set $SEEDDMS_HOME before running this script'
exit 1
parentdir=$(dirname "$0")
export SEEDDMS_HOME=$(dirname "$parentdir")
fi
exec php -f "${SEEDDMS_HOME}/utils/createfolder.php" -- "${@}"

View File

@ -8,23 +8,23 @@ if(isset($_SERVER['SEEDDMS_HOME'])) {
}
function usage() { /* {{{ */
echo "Usage:\n";
echo " seeddms-xmldump [-h] [-v] [--config <file>]\n";
echo "\n";
echo "Description:\n";
echo " This program creates an xml dump of the whole or parts of the dms.\n";
echo "\n";
echo "Options:\n";
echo " -h, --help: print usage information and exit.\n";
echo " -v, --version: print version and exit.\n";
echo " --config: set alternative config file.\n";
echo " --folder: set start folder.\n";
echo " --skip-root: do not export the root folder itself.\n";
echo " --sections <sections>: comma seperated list of sections to export.\n";
echo " --maxsize: maximum size of files to be included in output\n";
echo " (defaults to 100000)\n";
echo " --contentdir: directory where all document versions are stored\n";
echo " which are larger than maxsize.\n";
echo "Usage:".PHP_EOL;
echo " seeddms-xmldump [-h] [-v] [--config <file>]".PHP_EOL;
echo PHP_EOL;
echo "Description:".PHP_EOL;
echo " This program creates an xml dump of the whole or parts of the dms.".PHP_EOL;
echo PHP_EOL;
echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.".PHP_EOL;
echo " --config: set alternative config file.".PHP_EOL;
echo " --folder: set start folder.".PHP_EOL;
echo " --skip-root: do not export the root folder itself.".PHP_EOL;
echo " --sections <sections>: comma seperated list of sections to export.".PHP_EOL;
echo " --maxsize: maximum size of files to be included in output".PHP_EOL;
echo " (defaults to 100000)".PHP_EOL;
echo " --contentdir: directory where all document versions are stored".PHP_EOL;
echo " which are larger than maxsize.".PHP_EOL;
} /* }}} */
function wrapWithCData($text) { /* {{{ */
@ -50,7 +50,7 @@ if(isset($options['h']) || isset($options['help'])) {
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version."\n";
echo $version.PHP_EOL;
exit(0);
}
@ -75,7 +75,7 @@ if(isset($options['contentdir'])) {
if(substr($contentdir, -1, 1) != DIRECTORY_SEPARATOR)
$contentdir .= DIRECTORY_SEPARATOR;
} else {
echo "Directory ".$options['contentdir']." does not exists\n";
echo "Directory ".$options['contentdir']." does not exists".PHP_EOL;
exit(1);
}
} else {

View File

@ -8,26 +8,26 @@ if(isset($_SERVER['SEEDDMS_HOME'])) {
}
function usage() { /* {{{ */
echo "Usage:\n";
echo " seeddms-xmlimport [-h] [-v] [--config <file>]\n";
echo "\n";
echo "Description:\n";
echo " This program imports an xml dump into the dms.\n";
echo "\n";
echo "Options:\n";
echo " -h, --help: print usage information and exit.\n";
echo " -v, --version: print version and exit.\n";
echo " --config <config file>: set alternative config file.\n";
echo " --folder <folder id>: set import folder.\n";
echo " --file <file>: file containing the dump.\n";
echo " --sections <sections>: comma seperated list of sections to read from dump.\n";
echo " can be: users, groups, documents, folders, keywordcategories, or\n";
echo " documentcategories\n";
echo " --contentdir <dir>: directory where all document versions are stored\n";
echo " which are not included in the xml file.\n";
echo " --default-user <user id>: use this user if user could not be found.\n";
echo " --export-mapping <file>: write object mapping into file\n";
echo " --debug: turn debug output on\n";
echo "Usage:".PHP_EOL;
echo " seeddms-xmlimport [-h] [-v] [--config <file>]".PHP_EOL;
echo PHP_EOL;
echo "Description:".PHP_EOL;
echo " This program imports an xml dump into the dms.".PHP_EOL;
echo PHP_EOL;
echo "Options:".PHP_EOL;
echo " -h, --help: print usage information and exit.".PHP_EOL;
echo " -v, --version: print version and exit.".PHP_EOL;
echo " --config <config file>: set alternative config file.".PHP_EOL;
echo " --folder <folder id>: set import folder.".PHP_EOL;
echo " --file <file>: file containing the dump.".PHP_EOL;
echo " --sections <sections>: comma seperated list of sections to read from dump.".PHP_EOL;
echo " can be: users, groups, documents, folders, keywordcategories, or".PHP_EOL;
echo " documentcategories".PHP_EOL;
echo " --contentdir <dir>: directory where all document versions are stored".PHP_EOL;
echo " which are not included in the xml file.".PHP_EOL;
echo " --default-user <user id>: use this user if user could not be found.".PHP_EOL;
echo " --export-mapping <file>: write object mapping into file".PHP_EOL;
echo " --debug: turn debug output on".PHP_EOL;
} /* }}} */
function dateToTimestamp($date, $format='Y-m-d H:i:s') { /* {{{ */
@ -515,7 +515,7 @@ function insert_document($document) { /* {{{ */
copy($contentdir.$initversion['fileref'], $filename);
} else {
if(!isset($initversion['data']))
echo $document['attributes']['name']."\n";
echo $document['attributes']['name'].PHP_EOL;
$filecontents = base64_decode($initversion['data']);
if(strlen($filecontents) != $initversion['data_length']) {
$logger->warning("File length (".strlen($filecontents).") doesn't match expected length (".$initversion['data_length'].").");
@ -1618,7 +1618,7 @@ if(isset($options['h']) || isset($options['help'])) {
/* Print version and exit */
if(isset($options['v']) || isset($options['verѕion'])) {
echo $version."\n";
echo $version."".PHP_EOL;
exit(0);
}