2013-04-18 20:18:46 +00:00
|
|
|
|
<?php
|
|
|
|
|
/***************************************************************
|
|
|
|
|
* Copyright notice
|
|
|
|
|
*
|
|
|
|
|
* (c) 2013 Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* All rights reserved
|
|
|
|
|
*
|
|
|
|
|
* This script is part of the SeedDMS project. The SeedDMS project 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.
|
|
|
|
|
*
|
|
|
|
|
* The GNU General Public License can be found at
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
|
*
|
|
|
|
|
* This script 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.
|
|
|
|
|
*
|
|
|
|
|
* This copyright notice MUST APPEAR in all copies of the script!
|
|
|
|
|
***************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Example extension
|
|
|
|
|
*
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @subpackage example
|
|
|
|
|
*/
|
|
|
|
|
class SeedDMS_ExtExample extends SeedDMS_ExtBase {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialization
|
2013-05-02 16:24:25 +00:00
|
|
|
|
*
|
|
|
|
|
* Use this method to do some initialization like setting up the hooks
|
2013-05-03 11:24:27 +00:00
|
|
|
|
* You have access to the following global variables:
|
2020-06-25 06:56:41 +00:00
|
|
|
|
* $this->settings : current global configuration
|
|
|
|
|
* $this->settings->_extensions['example'] : configuration of this extension
|
2013-05-03 11:24:27 +00:00
|
|
|
|
* $GLOBALS['LANG'] : the language array with translations for all languages
|
|
|
|
|
* $GLOBALS['SEEDDMS_HOOKS'] : all hooks added so far
|
2013-04-18 20:18:46 +00:00
|
|
|
|
*/
|
|
|
|
|
function init() { /* {{{ */
|
2018-09-29 13:59:11 +00:00
|
|
|
|
$GLOBALS['SEEDDMS_HOOKS']['initDMS'][] = new SeedDMS_ExtExample_InitDMS;
|
2013-07-21 17:29:04 +00:00
|
|
|
|
$GLOBALS['SEEDDMS_HOOKS']['view']['addDocument'][] = new SeedDMS_ExtExample_AddDocument;
|
|
|
|
|
$GLOBALS['SEEDDMS_HOOKS']['view']['viewFolder'][] = new SeedDMS_ExtExample_ViewFolder;
|
2017-04-20 08:03:13 +00:00
|
|
|
|
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['example']['example'] = new SeedDMS_ExtExample_Task;
|
2013-04-18 20:18:46 +00:00
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
|
function main() { /* {{{ */
|
|
|
|
|
} /* }}} */
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-11 07:39:02 +00:00
|
|
|
|
class SeedDMS_ExtExample_HomeController { /* {{{ */
|
|
|
|
|
|
|
|
|
|
protected $dms;
|
|
|
|
|
|
|
|
|
|
protected $settings;
|
|
|
|
|
|
|
|
|
|
public function __construct($dms, $settings) {
|
|
|
|
|
$this->dms = $dms;
|
|
|
|
|
$this->settings = $settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function home($request, $response, $args) {
|
|
|
|
|
$response->getBody()->write('Output of route /ext/example/home'.get_class($this->dms));
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function echos($request, $response, $args) {
|
|
|
|
|
$response->getBody()->write('Output of route /ext/example/echo');
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|
2018-09-29 13:59:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* Class containing methods for hooks when the dms is initialized
|
|
|
|
|
*
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @subpackage example
|
|
|
|
|
*/
|
|
|
|
|
class SeedDMS_ExtExample_InitDMS { /* {{{ */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hook after initializing the application
|
|
|
|
|
*
|
|
|
|
|
* This method sets the callback 'onAttributeValidate' in SeedDMS_Core
|
|
|
|
|
*/
|
|
|
|
|
public function addRoute($arr) { /* {{{ */
|
|
|
|
|
$dms = $arr['dms'];
|
|
|
|
|
$settings = $arr['settings'];
|
|
|
|
|
$app = $arr['app'];
|
|
|
|
|
|
2018-10-11 07:39:02 +00:00
|
|
|
|
$container = $app->getContainer();
|
|
|
|
|
$container['HomeController'] = function($c) use ($dms, $settings) {
|
|
|
|
|
// $view = $c->get("view"); // retrieve the 'view' from the container
|
|
|
|
|
return new SeedDMS_ExtExample_HomeController($dms, $settings);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$app->get('/ext/example/home', 'HomeController:home');
|
|
|
|
|
|
|
|
|
|
$app->get('/ext/example/echos',
|
2018-09-29 13:59:11 +00:00
|
|
|
|
function ($request, $response) use ($app) {
|
|
|
|
|
echo "Output of route /ext/example/echo";
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
return null;
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|
2013-05-02 16:24:25 +00:00
|
|
|
|
/**
|
|
|
|
|
* Class containing methods for hooks when a document is added
|
|
|
|
|
*
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @subpackage example
|
|
|
|
|
*/
|
2013-04-30 21:03:27 +00:00
|
|
|
|
class SeedDMS_ExtExample_AddDocument {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hook before adding a new document
|
|
|
|
|
*/
|
2013-07-21 17:29:04 +00:00
|
|
|
|
function preAddDocument($view) { /* {{{ */
|
2013-04-30 21:03:27 +00:00
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hook after successfully adding a new document
|
|
|
|
|
*/
|
2013-07-21 17:29:04 +00:00
|
|
|
|
function postAddDocument($view) { /* {{{ */
|
2013-04-30 21:03:27 +00:00
|
|
|
|
} /* }}} */
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-02 16:24:25 +00:00
|
|
|
|
/**
|
|
|
|
|
* Class containing methods for hooks when a folder view is ѕhown
|
|
|
|
|
*
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @subpackage example
|
|
|
|
|
*/
|
2013-05-02 10:11:33 +00:00
|
|
|
|
class SeedDMS_ExtExample_ViewFolder {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hook when showing a folder
|
|
|
|
|
*
|
|
|
|
|
* The returned string will be output after the object menu and before
|
|
|
|
|
* the actual content on the page
|
|
|
|
|
*
|
|
|
|
|
* @param object $view the current view object
|
|
|
|
|
* @return string content to be output
|
|
|
|
|
*/
|
|
|
|
|
function preContent($view) { /* {{{ */
|
2013-07-31 15:25:50 +00:00
|
|
|
|
return $view->infoMsg("Content created by viewFolder::preContent hook.");
|
2013-05-02 10:11:33 +00:00
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hook when showing a folder
|
|
|
|
|
*
|
|
|
|
|
* The returned string will be output at the end of the content area
|
|
|
|
|
*
|
|
|
|
|
* @param object $view the current view object
|
|
|
|
|
* @return string content to be output
|
|
|
|
|
*/
|
|
|
|
|
function postContent($view) { /* {{{ */
|
|
|
|
|
return $view->infoMsg("Content created by viewFolder::postContent hook");
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-20 08:03:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* Class containing methods for running a scheduled task
|
|
|
|
|
*
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @subpackage example
|
|
|
|
|
*/
|
2018-04-04 13:31:57 +00:00
|
|
|
|
class SeedDMS_ExtExample_Task extends SeedDMS_SchedulerTaskBase {
|
2018-07-12 11:55:36 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Run the task
|
|
|
|
|
*
|
|
|
|
|
* @param $task task to be executed
|
|
|
|
|
* @return boolean true if task was executed succesfully, otherwise false
|
|
|
|
|
*/
|
2021-04-21 15:44:17 +00:00
|
|
|
|
public function execute($task) {
|
|
|
|
|
$dms = $this->dms;
|
|
|
|
|
$user = $this->user;
|
|
|
|
|
$settings = $this->settings;
|
|
|
|
|
$logger = $this->logger;
|
2018-07-12 11:55:36 +00:00
|
|
|
|
$taskparams = $task->getParameter();
|
2018-04-04 13:31:57 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
|
return 'Description';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getAdditionalParams() {
|
|
|
|
|
return array(array(
|
|
|
|
|
'name'=>'email',
|
|
|
|
|
'type'=>'string',
|
|
|
|
|
'description'=> '',
|
|
|
|
|
));
|
2017-04-20 08:03:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|