Document samples

Basics

On most methods you'll see parameter named "docId". The value of this parameter can be a valid document UUID or path.

Example of docId:

  • Using UUID -> "68a27519-c9cc-4490-b281-19ff9f19318b";
  • Using path -> "/okm:root/SDK4PHP/logo.png"

Methods

createDocumentSimple

Description:

MethodReturn valuesDescription

createDocumentSimple($docPath, $content)

Document

Creates a new document and returns as a result an object Document with the properties of the created document.

Parameters:
$docPath string type is the Path of the Document

$content string type is recommend using file_get_contents — Reads entire file into a string

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCreateDocumentSimple() {
        try {
            $fileName = dirname(__FILE__) . '/files/logo.png';
            $docPath = '/okm:root/SDK4PHP/logo.png';
            $document = $this->ws->createDocumentSimple($docPath, file_get_contents($fileName));
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCreateDocumentSimple();
?>

deleteDocument

Description:

MethodReturn valuesDescription

deleteDocument($docId)

void

Deletes a document.

Parameters:
$docId string type is the uuid or path of the Document

When a document is deleted, it is automatically moved to /okm:trash/userId folder.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testDeleteDocument(){
        try {            
            $this->ws->deleteDocument('/okm:root/SDK4PHP/logo.png');
            echo 'deleted';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testDeleteDocument();
?>

getDocumentProperties

Description:

MethodReturn valuesDescription

getDocumentProperties($docId)

Document

Returns the document properties.

Parameters:
$docId
string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetDocumentProperties() {
        try {
            $document = $this->ws->getDocumentProperties('/okm:root/SDK4PHP/logo.png');
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetDocumentProperties();
?>

getContent

Description:

MethodReturn valuesDescription

getContent($docId)

string

Retrieves a document content - binary data - of the actual document version.

Parameters:
$docId
string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetContent($method) {
        $content = $this->ws->getContent('/okm:root/SDK4PHP/logo.png');
        switch ($method) {
            case 1:
                $file = fopen(dirname(__FILE__) . '/files/logo_download.png', 'w+');
                fwrite($file, $content);
                fclose($file);
                echo 'download correct';
                break;
            case 2:
                $document = $this->ws->getDocumentProperties('/okm:root/SDK4PHP/logo.png');
                header('Expires', 'Sat, 6 May 1971 12:00:00 GMT');
                header('Cache-Control', 'max-age=0, must-revalidate');
                header('Cache-Control', 'post-check=0, pre-check=0');
                header('Pragma', 'no-cache');
                header('Content-Type: ' . $document->getMimeType());
                header('Content-Disposition: attachment; filename="' . substr($document->getPath(), strrpos($document->getPath(), '/') + 1) . '"');
                echo $content;
                break;
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetContent(2);
?>

getContentByVersion

Description:

MethodReturn valuesDescription

getContentByVersion($docId, $versionId)

string

Retrieves a document content ( binary data ) of some specific document version.

Parameters:
$docId
string type is the uuid or path of the Document

$versionId string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGetContentByVersion($method) {
        $content = $this->ws->getContentByVersion('/okm:root/SDK4PHP/logo.png',1.1);
        switch ($method) {
            case 1:
                $file = fopen(dirname(__FILE__) . '/files/logo_download_version.png', 'w+');
                fwrite($file, $content);
                fclose($file);
                echo 'download correct';
                break;
            case 2:
                $document = $this->ws->getDocumentProperties('/okm:root/SDK4PHP/logo.png');
                header('Expires', 'Sat, 6 May 1971 12:00:00 GMT');
                header('Cache-Control', 'max-age=0, must-revalidate');
                header('Cache-Control', 'post-check=0, pre-check=0');
                header('Pragma', 'no-cache');
                header('Content-Type: ' . $document->getMimeType());
                header('Content-Disposition: attachment; filename="' . substr($document->getPath(), strrpos($document->getPath(), '/') + 1) . '"');
                echo $content;
                break;
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetContentByVersion(1);
?>

getExtractedText

Description:

MethodReturn valuesDescription

getExtractedText($docId)

string

Returns a String with the extracted text by text extractor process.

Parameters:
$docId
string type is the uuid or path of the Document

When a document is uploaded into OpenKM goes into text extraction queue. There's a crontab tab that periodically process this queue and extract document contents.

Unfortunately there is not a direct way to know if a document has been processed or not from the API, because this information is only stored at the database level.

Although this restriction, from API - only administrators users - can perform database queries to retrieve this information. Check Repository samples accessing database level.

More information at Statistics.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\QueryParams;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGetExtractedText(){
        try {
             $text = $this->ws->getExtractedText('/okm:root/SDK4PHP/document.odt');
            var_dump($text);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetExtractedText();
?>

getThumbnail

Description:

MethodReturn valuesDescription

 getThumbnail($docId, ThumbnailType $type)

string

Returns thumbnail image data.

Parameters:
$docId
string type is the uuid or path of the Document

$type string type

Available types:

  • ThumbnailType::THUMBNAIL_PROPERTIES ( shown in properties view )
  • ThumbnailType::THUMBNAIL_LIGHTBOX ( shown in light box )
  • ThumbnailType::THUMBNAIL_SEARCH ( shown in search view )

Each thumbnail type has its own image dimensions.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetThumbnail($method) {
        try {
            $content = $this->ws->getThumbnail('/okm:root/SDK4PHP/document.odt', \openkm\bean\ThumbnailType::THUMBNAIL_LIGHTBOX);
            switch ($method) {
                case 1:
                    $file = fopen(dirname(__FILE__) . '/files/thumbnail.png', 'w+');
                    fwrite($file, $content);
                    fclose($file);
                    echo 'download correct';
                    break;
                case 2:
                    header('Expires', 'Sat, 6 May 1971 12:00:00 GMT');
                    header('Cache-Control', 'max-age=0, must-revalidate');
                    header('Cache-Control', 'post-check=0, pre-check=0');
                    header('Pragma', 'no-cache');
                    header('Content-Type: ' . \openkm\util\MimeTypeConfig::MIME_PNG);
                    header('Content-Disposition: attachment; filename="thumbnail.png"');
                    echo $content;
                    break;
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetThumbnail(1);
?>

getDocumentChildren

Description:

MethodReturn valuesDescription

getDocumentChildren($fldId)

array

Returns a list of all documents which their parent is fldId.

Parameters:
$fldId
string type is the uuid or path of the Document or a record node.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGetDocumentChildren(){
        try {
            $documents = $this->ws->getDocumentChildren('/okm:root');
            foreach ($documents as $document) {
                var_dump($document);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetDocumentChildren();
?>

renameDocument

Description:

MethodReturn valuesDescription

renameDocument($docId, $newName)

Document

Changes the name of a document and returns the Document

Parameters:
$docId
string type is the uuid or path of the Document

$newName string type is the new name for the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testRenameDocument() {
        try {
            $document = $this->ws->renameDocument('604e17e8-3285-4e8a-910c-c99ee4e44262', 'logo_rename.png');
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testRenameDocument();
?>

setProperties

Description:

MethodReturn valuesDescription

 setProperties(Document $doc)

void

Change some document properties.

Variables allowed to be changed:

  • Title
  • Description
  • Language
  • Associated categories
  • Associated keywords

The parameter Language must be ISO 691-1 compliant.

Only not null and not empty variables will be take on consideration.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testSetProperties(){
        try {
            $document = $this->ws->getDocumentProperties('604e17e8-3285-4e8a-910c-c99ee4e44262');            
            $document->setTitle('Logo');
            $document->setDescription('some description'); 
            $document->setLanguage('es');
            //Keywords
            $keywords = array();
            $keywords[] = 'test';
            $document->setKeywords($keywords);
            //Categories
            $categories = array();
            $category = $this->ws->getFolderProperties('/okm:categories/test');
            $categories[] = $category;            
            $document->setCategories($categories);
            
            $this->ws->setProperties($document);
            echo 'updated';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testSetProperties();
?>

setLanguage

Description:

MethodReturn valuesDescription

setLanguage($docId, $lang)

void

Sets document language.

Parameters:
$docId
string type is the uuid or path of the Document

$lang string type is the lang must be ISO 691-1 compliant.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testSetLanguage() {
        try {
            $this->ws->setLanguage('/okm:root/SDK4PHP/document.odt', 'es');
            echo 'updated';
        } catch (Exception $e) {
            var_dump($e);
        }
    }    
}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testSetLanguage();
?>

setDocumentTitle

Description:

MethodReturn valuesDescription

setDocumentTitle($docId, $title)

void

Set document title.

Parameters:
$docId
string type is the uuid or path of the Document

$title string type is the title of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testSetDocumentTitle() {
        try {
            $this->ws->setDocumentTitle('/okm:root/SDK4PHP/document.odt', 'Some title here');
            echo 'updated';
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testSetDocumentTitle();
?>

createFromTemplate

checkout

Description:

MethodReturn valuesDescription

 checkout($docId)

void

Mark the document for edition.

Parameters:
$docId
string type is the uuid or path of the Document

Only one user can modify a document at same time.

Before starting edition you must perform a checkout action that locks the edition process for other users and allows it only to the user who has executed the action.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCheckout() {
        try {
            $this->ws->checkout('/okm:root/SDK4PHP/logo.png');
            // At this point the document is locked for other users except for the user who executed the action
            echo 'correct';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCheckout();
?>

cancelCheckout

Description:

MethodReturn valuesDescription

cancelCheckout($docId)

void

Cancels a document edition.

Parameters:
$docId
string type is the uuid or path of the Document

This action can only be done by the user who previously executed the checkout action.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCancelCheckout() {
        try {
            // At this point the document is locked for other users except for the user who executed the action
            $this->ws->cancelCheckout('/okm:root/SDK4PHP/logo.png');
            // At this point other users are allowed to execute a checkout and modify the document
            echo 'correct';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCancelCheckout();
?>

forceCancelCheckout

Description:

MethodReturn valuesDescription

forceCancelCheckout($docId)

void

Cancels a document edition.

Parameters:
$docId
string type is the uuid or path of the Document

This method allows to cancel edition on any document.

It is not mandatory that this action is executed by the same user who previously executed the checkout action.

This action can only be done by a super user ( user with ROLE_ADMIN ).

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testForceCancelCheckout() {
        try {
            // At this point the document is locked for other users except for the user who executed the action
            $this->ws->forceCancelCheckout('/okm:root/SDK4PHP/logo.png');
            // At this point other users are allowed to execute a checkout and modify the document
            echo 'correct';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testForceCancelCheckout();
?>

isCheckedOut

Description:

MethodReturn valuesDescription

isCheckedOut($docId)

bool

Returns a boolean that indicate if the document is on edition or not.

Parameters:
$docId
string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testIsCheckedOut() {
        try {            
            echo "Is the document checkout:" . $this->ws->isCheckedOut('/okm:root/SDK4PHP/logo.png');           
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testIsCheckedOut();
?>

checkin

Description:

MethodReturn valuesDescription

checkin($docId, $content, $comment,$increment)

Version

Updates a document with new version and return an object with new Version values.

Parameters:
$docId
string type is the uuid or path of the Document

$content string type is recommend using file_get_contents — Reads entire file into a string

$comment string type is the comment for the new version the document

$increment int type

The value of increment variable must be 1 or greater.

The valid values of increment variable depends on the VersionNumberAdapter you  have enabled.

Only the user who started the edition - checkout - is allowed to update the document.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testCheckin() {
        try {
            $fileName = dirname(__FILE__) . '/files/logo.png';            
            $version = $this->ws->checkin('/okm:root/SDK4PHP/logo.png', file_get_contents($fileName),"optional some comment");
            var_dump($version);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCheckin();
?>

getVersionHistory

Description:

MethodReturn valuesDescription

getVersionHistory($docId)

array

Returns a list of all document versions.

Parameters:
$docId
string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

//ini_set('display_errors', true);
//error_reporting(E_ALL);

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGetVersionHistory() {
        try {
            $versions = $this->ws->getVersionHistory('/okm:root/SDK4PHP/logo.png');
            foreach ($versions as $version) {
                var_dump($version);    
            }                        
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetVersionHistory();
?>

lock

Description:

MethodReturn valuesDescription

lock($docId)

LockInfo

Locks a document and returns an object with the Lock information.

Parameters:
$docId
string type is the uuid or path of the Document

Only the user who locked the document is allowed to unlock.

A locked document can not be modified by other users.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testLock() {
        try {
            $lockInfo = $this->ws->lock('/okm:root/SDK4PHP/logo.png');
            var_dump($lockInfo);                  
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testLock();
?>

unlock

Description:

MethodReturn valuesDescription

unlock($docId)

void

Unlocks a locked document.

Parameters:
$docId
string type is the uuid or path of the Document

Only the user who locked the document is allowed to unlock.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testUnlock() {
        try {
            $this->ws->unlock('/okm:root/SDK4PHP/logo.png');
            echo 'unlock';         
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testUnlock();
?>

forceUnlock

Description:

MethodReturn valuesDescription

forceUnlock($docId)

void

Unlocks a locked document.

Parameters:
$docId
string type is the uuid or path of the Document

This method allows to unlcok any locked document.

It is not mandatory execute this action by the same user who previously executed the checkout lock action.

This action can only be done by a super user ( user with ROLE_ADMIN ).

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testForceUnlock() {
        try {
            $this->ws->forceUnlock('/okm:root/SDK4PHP/logo.png');
            echo 'forceUnlock';         
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testForceUnlock();
?>

isLocked

Description:

MethodReturn valuesDescription

isLocked($docId)

bool

Returns a boolean that indicate if the document is locked or not.

Parameters:
$docId
string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testIsLocked() {
        try {
            echo "Is document locked:" . $this->ws->isLocked('/okm:root/SDK4PHP/logo.png');
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testIsLocked();
?>

getLockInfo

Description:

MethodReturn valuesDescription

getLockInfo($docId)

LockInfo

Returns an object with the Lock information

Parameters:
$docId
string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGetLockInfo() {
        try {
            var_dump($this->ws->getLockInfo('/okm:root/SDK4PHP/logo.png'));
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetLockInfo();
?>

purgeDocument

Description:

MethodReturn valuesDescription

purgeDocument($docId)

void

Document is definitely removed from repository.

Parameters:
$docId
string type is the uuid or path of the Document

Usually you will purge documents into /okm:trash/userId - the personal trash user locations - but it is possible to directly purge any document from the whole repository.

When a document is purged it will only be able to be restored from a previously repository backup. The purge action removes the document definitely from the repository.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testPurgeDocument() {
        try {
            $this->ws->purgeDocument('/okm:root/SDK4PHP/logo.png');
            echo 'purgeDocument';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testPurgeDocument();
?>

moveDocument

Description:

MethodReturn valuesDescription

moveDocument($docId, $dstId)

void

Move a document into some folder or record.

Parameters:
$docId
string type is the uuid or path of the Document

$dstId string type is the uuid or path of the Folder or Record

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testMoveDocument() {
        try {
            $this->ws->moveDocument('/okm:root/SDK4PHP/logo.png','/okm:root/SDK4PHP/tmp');
            echo 'moveDocument';
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testMoveDocument();
?>

copyDocument

Description:

MethodReturn valuesDescription

copyDocument($docId, $dstId, $newName)

void

Copies a document to a folder or record.

Parameters:
$docId
string type is the uuid or path of the Document

$dstId string type is the uuid or path of the Folder or Record

$newName string type is the new name for the Document

When parameter newName value is null, document will preservate the same name.

Only the binary data and the security grants are copied to destionation, the metadata, keywords, etc. of the document are not copied.

See "extendedDocumentCopy" method for this feature.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testCopyDocument() {
        try {
            $this->ws->copyDocument('/okm:root/SDK4PHP/logo.png','/okm:root/SDK4PHP/tmp','new_logo.png');
            echo 'copyDocument';
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCopyDocument();
?>

restoreVersion

Description:

MethodReturn valuesDescription

restoreVersion($docId, $versionId)

void

Promotes previous document's version to the actual version.

Parameters:
$docId
string type is the uuid or path of the Document

$versionId string type is the version of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testRestoreVersion() {
        try {
            $this->ws->restoreVersion('/okm:root/SDK4PHP/logo.png','1.1');
            echo 'restoreVersion';
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testRestoreVersion();
?>

purgeVersionHistory

Description:

MethodReturn valuesDescription

purgeVersionHistory($docId)

void

Purges all documents version except the actual version.

Parameters:
$docId
string type is the uuid or path of the Document

This action compact the version history of a document.

This action can not be reverted.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testPurgeVersionHistory() {
        try {
            // Version history has version 1.3,1.2,1.1 and 1.0
            $this->ws->purgeVersionHistory('/okm:root/SDK4PHP/logo.png');
            // Version history has only version 1.3
            echo 'purgeVersionHistory';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testPurgeVersionHistory();
?>

getVersionHistorySize

Description:

MethodReturn valuesDescription

getVersionHistorySize($docId)

int

Returns the sum in bytes of all documents into documents history.

Parameters:
$docId
string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetVersionHistorySize() {
        try {
            $units = array("B", "KB", "MB", "GB", "TB", "PB", "EB");

            $bytes = $this->ws->getVersionHistorySize('/okm:root/SDK4PHP/logo.png');
            $value = "";

            for ($i = 6; $i > 0; $i--) {
                $step = pow(1024, $i);
                if ($bytes > $step) {
                    $value = number_format($bytes / $step, 2) . ' ' . $units[$i];
                }
                if (empty($value)) {
                    $value = $bytes . ' ' . $units[0];
                }
            }
            echo $value;
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetVersionHistorySize();
?>

isValidDocument

Description:

MethodReturn valuesDescription

isValidDocument($docId)

bool

Returns a boolean that indicates if the node is a document or not.

Parameters:
$docId
string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testIsValidDocument() {
        try {
            // Return true
            var_dump($this->ws->isValidDocument("/okm:root/SDK4PHP/logo.png"));
            // Return false
            var_dump($this->ws->isValidDocument('/okm:root'));
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testIsValidDocument();
?>

getDocumentPath

Description:

MethodReturn valuesDescription

getDocumentPath($uuid)

string

Converts a document UUID to a document path.

Parameters:
$uuid
string type is the uuid of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testGetDocumentPath() {
        try {
            var_dump($this->ws->getDocumentPath("8b559709-3c90-4c26-b181-5192a17362b2"));            
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetDocumentPath();
?>

getDetectedLanguages

Description:

MethodReturn valuesDescription

getDetectedLanguages()

array

Return a list of available document languages what OpenKM can identify

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetDetectedLanguages() {
        try {
            var_dump($this->ws->getDetectedLanguages());            
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetDetectedLanguages();
?>

extendedDocumentCopy

Description:

MethodReturn valuesDescription

extendedDocumentCopy($docId, $dstId, $name, $categories, $keywords,
            $propertyGroups, $notes, $wiki)

void

Copies a document with associated data into a folder or record.

Parameters:
$docId
string type is the uuid or path of the Document

$dstId string type is the uuid or path of the Folder or Record

$name string type is the new name for the Document. Value is null, document will preservate the same name.

$categories bool type

$keywords bool type

$propertyGroups bool type

$notes bool type

$wiki bool type

By default only the binary data and the security grants, the metadata, keywords, etc. of the document are not copied.

Additional:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When  the propertyGroups parameter is true the original values of the metadata groups will be copied.
  • When  the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

   

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testExtendedDocumentCopy() {
        try {
            $this->ws->extendedDocumentCopy('/okm:root/SDK4PHP/logo.png', '/okm:root/SDK4PHP/tmp', '', true, true, true, true, true);            
            echo 'extendedDocumentCopy';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testExtendedDocumentCopy();
?>

createFromTemplate

Description:

MethodReturn valuesDescription

Document createFromTemplate($docId, $dstPath,$categories,$keywords,
            $propertyGroups, $notes, $wiki, $formElements)

Document

Creates a new document from template and returns an object Document.

Parameters:
$docId
string type is the uuid or path of the Document

$dstPath string type is the path of the Document

$categories bool type

$keywords bool type

$propertyGroups bool type

$notes bool type

$wiki bool type

$formElements array type is an array of the FormElement

When template use metadata groups to fill fields into, then these values are mandatory and must be set into properties parameter. 

For more information about Templates and metadata take a look at Creating templates.

Additional:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the propertyGroups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

Example:

The example below is based on Creating PDF template sample.

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }
    
    public function testCreateFromTemplate() {
        try {
            $formElements = array();
            
            $name = new \openkm\bean\form\Input();
            $name->setName('okp:tpl.name');
            $name->setValue('Some name');
            $formElements[] = $name;
            
            $birdDate = new \openkm\bean\form\Input();
            $birdDate->setName('okp:tpl.bird_date');
            // Value must be converted to String ISO 8601 compliant
            $birdDate->setValue(date('Ymdhis'));
            $formElements[] = $birdDate;
        
            $language = new \openkm\bean\form\Select();
            $language->setName('okp:tpl.language');
            
            $options = array();
            $option = new \openkm\bean\form\Option();            
            $option->setValue('php');
            $option->setSelected(true);
            $options[] = $option;
            $language->setOptions($options);
            $formElements[] = $language;
            
            $document = $this->ws->createFromTemplate('/okm:templates/tpl.pdf', '/okm:root/SDK4PHP/test.pdf', false, false, true, false,false,$formElements);            
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCreateFromTemplate();
?>

createFromTemplateSimple

Description:

MethodReturn valuesDescription

Document createFromTemplateSimple($docId, $dstPath, $categories,
            $keywords, $propertyGroups, $notes, $wiki, $properties)

Document

Creates a new document from template and returns an object Document.

Parameters:
$docId
string type is the uuid or path of the Document

$dstPath string type is the path of the Document

$categories bool type

$keywords bool type

$propertyGroups bool type

$notes bool type

$wiki bool type

$properties array type is an array of the SimplePropertyGroup

When template use metadata groups to fill fields into, then these values are mandatory and must be set into properties parameter. 

For more information about Templates and metadata take a look at Creating templates.

Additional:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the propertyGroups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

Example:

The example below is based on Creating PDF template sample.

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCreateFromTemplateSimple() {
        try {
            $properties = array();

            $name = new \openkm\bean\SimplePropertyGroup();
            $name->setName('okp:tpl.name');
            $name->setValue('Some name');
            $properties[] = $name;

            $birdDate = new \openkm\bean\SimplePropertyGroup();
            $birdDate->setName('okp:tpl.bird_date');
            // Value must be converted to String ISO 8601 compliant
            $birdDate->setValue(date('Ymdhis'));
            $properties[] = $birdDate;

            $language = new \openkm\bean\SimplePropertyGroup();
            $language->setName('okp:tpl.language');
            $language->setValue('php');
            $properties[] = $language;

            $document = $this->ws->createFromTemplateSimple('/okm:templates/tpl.pdf', '/okm:root/SDK4PHP/test.pdf', false, false, true, false, false, $properties);
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testCreateFromTemplateSimple();
?>

updateFromTemplate

Description:

MethodReturn valuesDescription

Document updateFromTemplate($docId, $dstId, $formElements)

Document

Update a document previously created from template and returns an object Document.

Parameters:
$docId
string type is the uuid or path of the Document

$dstId string type is the uuid or path of the Document

$formElements array type is an array of the FormElement

This method only has sense when template use metadata groups to fill fields into.

For more information about Templates and metadata take a look at Creating templates.

Example:

The example below is based on Creating PDF template sample.

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testUpdateFromTemplate() {
        try {
            $formElements = array();

            $name = new \openkm\bean\form\Input();
            $name->setName('okp:tpl.name');
            $name->setValue('Update name');
            $formElements[] = $name;

            $birdDate = new \openkm\bean\form\Input();
            $birdDate->setName('okp:tpl.bird_date');
            // Value must be converted to String ISO 8601 compliant
            $birdDate->setValue(date('Ymdhis'));
            $formElements[] = $birdDate;

            $language = new \openkm\bean\form\Select();
            $language->setName('okp:tpl.language');

            $options = array();
            $option = new \openkm\bean\form\Option();
            $option->setValue('go');
            $option->setSelected(true);
            $options[] = $option;
            $language->setOptions($options);
            $formElements[] = $language;

            $document = $this->ws->updateFromTemplate('/okm:templates/tpl.pdf', '/okm:root/SDK4PHP/test.pdf', $formElements);
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testUpdateFromTemplate();
?>

 

updateFromTemplateSimple

Description:

MethodReturn valuesDescription

updateFromTemplateSimple(String docId, String dstId, Map<String, String> properties) 

Document

Update a document previously created from template and return an object Document.

Parameters:
$docId
string type is the uuid or path of the Document

$dstId string type is the uuid or path of the Document

$properties array type is an array of the SimplePropertyGroup

This method only has sense when template use metadata groups to fill fields into.

For more information about Templates and metadata take a look at Creating templates.

Example:

The example below is based on Creating PDF template sample.

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testUpdateFromTemplateSimple() {
        try {
            $properties = array();

            $name = new \openkm\bean\SimplePropertyGroup();
            $name->setName('okp:tpl.name');
            $name->setValue('Update name');
            $properties[] = $name;

            $birdDate = new \openkm\bean\SimplePropertyGroup();
            $birdDate->setName('okp:tpl.bird_date');
            // Value must be converted to String ISO 8601 compliant
            $birdDate->setValue(date('Ymdhis'));
            $properties[] = $birdDate;

            $language = new \openkm\bean\SimplePropertyGroup();
            $language->setName('okp:tpl.language');
            $language->setValue('go');
            $properties[] = $language;

            $document = $this->ws->updateFromTemplateSimple('/okm:templates/tpl.pdf', '/okm:root/SDK4PHP/test.pdf', $properties);
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testUpdateFromTemplateSimple();
?>

getAnnotations

Description:

MethodReturn valuesDescription

getAnnotations($docId, $verName)  

string

Return the document annotations of some document version.

Parameters:
$docId
string type is the uuid or path of the Document

$verName string type is the version name of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetAnnotations(){
        try {            
            var_dump($this->ws->getAnnotations('e34af683-7a8f-447c-98fb-8417b399f8d5', '1.0'));
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetAnnotations();
?>

 

getDifferences

Description:

MethodReturn valuesDescription

getDifferences($docId, $v1, $v2)

string

Return a PDF document with the differences between two document versions.

Parameters:
$docId
string type is the uuid or path of the Document

$v1 string type is the version of the Document

 $v2 string type is the version of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetDifferences($method) {
        try {
            $content = $this->ws->getDifferences('e34af683-7a8f-447c-98fb-8417b399f8d5', '1.0', '1.1');
            switch ($method) {
                case 1:
                    $file = fopen(dirname(__FILE__) . '/files/text.csv', 'w+');
                    fwrite($file, $content);
                    fclose($file);
                    echo 'download correct';
                    break;
                case 2:
                    $document = $this->ws->getDocumentProperties('/test.csv');
                    header('Expires', 'Sat, 6 May 1971 12:00:00 GMT');
                    header('Cache-Control', 'max-age=0, must-revalidate');
                    header('Cache-Control', 'post-check=0, pre-check=0');
                    header('Pragma', 'no-cache');
                    header('Content-Type: ' . $document->getMimeType());
                    header('Content-Disposition: attachment; filename="' . substr($document->getPath(), strrpos($document->getPath(), '/') + 1) . '"');
                    echo $content;
                    break;
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetDifferences(1);
?>

getCheckedOut

Description:

MethodReturn valuesDescription

getCheckedOut()

array

Return a list of documents checkout by the user.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleDocument {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetCheckedOut() {
        try {
            $documents = $this->ws->getCheckedOut();
            foreach ($documents as $document) {
                var_dump($document);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleDocument = new ExampleDocument();
$exampleDocument->testGetCheckedOut();
?>