mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 20:21:16 +00:00
- added some test scripts
This commit is contained in:
parent
6c366b20ac
commit
69fe39cf3f
10
LetoDMS_Core/tests/config.php
Normal file
10
LetoDMS_Core/tests/config.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
$g_config['type'] = 'mysql';
|
||||
$g_config['hostname'] = 'localhost';
|
||||
$g_config['user'] = 'letodms';
|
||||
$g_config['passwd'] = 'letodms';
|
||||
$g_config['name'] = 'letodms';
|
||||
|
||||
$g_config['contentDir'] = '/tmp/content';
|
||||
$g_config['contentOffsetDir'] = '/tmp/content';
|
||||
?>
|
25
LetoDMS_Core/tests/getfoldertree.php
Normal file
25
LetoDMS_Core/tests/getfoldertree.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
include("config.php");
|
||||
include("LetoDMS/LetoDMS_Core.php");
|
||||
|
||||
$db = new LetoDMS_Core_DatabaseAccess($g_config['type'], $g_config['hostname'], $g_config['user'], $g_config['passwd'], $g_config['name']);
|
||||
$db->connect() or die ("Could not connect to db-server \"" . $g_config['hostname'] . "\"");
|
||||
|
||||
$dms = new LetoDMS_Core_DMS($db, $g_config['contentDir'], $g_config['contentOffsetDir']);
|
||||
|
||||
function tree($folder, $indent='') {
|
||||
echo $indent."D ".$folder->getName()."\n";
|
||||
$subfolders = $folder->getSubFolders();
|
||||
foreach($subfolders as $subfolder) {
|
||||
tree($subfolder, $indent.' ');
|
||||
}
|
||||
$documents = $folder->getDocuments();
|
||||
foreach($documents as $document) {
|
||||
echo $indent." ".$document->getName()."\n";
|
||||
}
|
||||
}
|
||||
|
||||
$folder = $dms->getFolder(1);
|
||||
tree($folder);
|
||||
|
||||
?>
|
14
LetoDMS_Core/tests/getusers.php
Normal file
14
LetoDMS_Core/tests/getusers.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
include("config.php");
|
||||
include("LetoDMS/LetoDMS_Core.php");
|
||||
|
||||
$db = new LetoDMS_Core_DatabaseAccess($g_config['type'], $g_config['hostname'], $g_config['user'], $g_config['passwd'], $g_config['name']);
|
||||
$db->connect() or die ("Could not connect to db-server \"" . $g_config['hostname'] . "\"");
|
||||
|
||||
$dms = new LetoDMS_Core_DMS($db, $g_config['contentDir'], $g_config['contentOffsetDir']);
|
||||
|
||||
$users = $dms->getAllUsers();
|
||||
foreach($users as $user)
|
||||
echo $user->getId()." ".$user->getLogin()." ".$user->getFullname()."\n";
|
||||
|
||||
?>
|
44
LetoDMS_Core/tests/reverselookup.php
Normal file
44
LetoDMS_Core/tests/reverselookup.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
include("config.php");
|
||||
include("LetoDMS/LetoDMS_Core.php");
|
||||
|
||||
$db = new LetoDMS_Core_DatabaseAccess($g_config['type'], $g_config['hostname'], $g_config['user'], $g_config['passwd'], $g_config['name']);
|
||||
$db->connect() or die ("Could not connect to db-server \"" . $g_config['hostname'] . "\"");
|
||||
|
||||
$dms = new LetoDMS_Core_DMS($db, $g_config['contentDir'], $g_config['contentOffsetDir']);
|
||||
|
||||
$path = '/Test 1/';
|
||||
echo "Searching for folder or document with path '".$path."'\n";
|
||||
|
||||
$root = $dms->getRootFolder();
|
||||
if($path[0] == '/') {
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
$patharr = explode('/', $path);
|
||||
/* The last entry is always the document, though if the path ends in '/' the
|
||||
* document name will be empty.
|
||||
*/
|
||||
$docname = array_pop($patharr);
|
||||
$parentfolder = $root;
|
||||
|
||||
foreach($patharr as $pathseg) {
|
||||
if($folder = $dms->getFolderByName($pathseg, $parentfolder)) {
|
||||
$parentfolder = $folder;
|
||||
}
|
||||
}
|
||||
if($folder) {
|
||||
if($docname) {
|
||||
if($document = $dms->getDocumentByName($docname, $folder)) {
|
||||
echo "Given path is document '".$document->getName()."'\n";
|
||||
} else {
|
||||
echo "No object found\n";
|
||||
}
|
||||
} else {
|
||||
echo "Given path is a folder '".$folder->getName()."'\n";
|
||||
}
|
||||
} else {
|
||||
echo "No object found\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user