Documentation/Index/DocumentFormOnToHtml: DocumentFormBeforeToHtml.inc

Plik DocumentFormBeforeToHtml.inc, 1.1 KB (dodany przez TS, 4 years temu)
xx
Line 
1<?php
2
3/**
4 * DocumentFormBeforeToHtml
5 *
6 * @author Tomasz Świenty
7 * @version 0.1
8 * @copyright Copyright (c) eDokumenty
9 */
10final class DocumentFormBeforeToHtml {
11
12
13    /**
14     * @param $args
15     * @return bool
16     */
17    public static function init($args) {
18
19        if (!isset($args['container'])) {
20            return FALSE;
21        }
22
23        if (!is_object($args['container']) OR !is_a($args['container'], 'Dialog')) {
24            return FALSE;
25        }
26
27        if (!isset($args['container']->docMenu) OR !is_a($args['container']->docMenu, 'JSMenu')) {
28            return FALSE;
29        }
30
31        $sData = $args['container']->getSData();
32        if (!isset($sData['dctpid']) OR ($sData['dctpid'] != 136)) {
33            return FALSE;
34        }
35
36        $items = $args['container']->docMenu->getItems();
37        foreach ($items as $name => $caption) {
38            if (strpos($name, 'cswgid') !== 0) {
39                $args['container']->docMenu->removeItem($name);
40            }
41        }
42
43        return TRUE;
44
45    }
46
47}
48
49if (isset($args)) {
50    DocumentFormBeforeToHtml::init($args);
51}