File: EntryWriter.php

package info (click to toggle)
phpldapadmin 1.1.0.5-6%2Blenny2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,008 kB
  • ctags: 3,949
  • sloc: php: 17,735; xml: 1,532; sh: 388; makefile: 46
file content (109 lines) | stat: -rw-r--r-- 2,911 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/EntryWriter.php,v 1.2.2.1 2008/01/27 06:48:59 wurley Exp $

define('ENTRY_WRITER_CREATION_CONTEXT', '1');
define('ENTRY_WRITER_EDITING_CONTEXT', '2');

/**
 * @package phpLDAPadmin
 * @author The phpLDAPadmin development team
 * @author Xavier Bruyet
 *
 * Visit an entry and its attributes to draw them
 */
class EntryWriter extends Visitor {
	# Ldapserver from context
	protected $index;

	# Context : creation or editing
	protected $context;

	# visited attributes
	protected $internal_attributes;
	protected $shown_attributes;
	protected $hidden_attributes;

	# are we visiting the attributes of an entry
	protected $visit_attributes;

	public function __construct($ldapserver) {
		$this->index = $ldapserver->server_id;
		$this->visit_attributes = true;
		$this->context = 0;
	}

	public function getLDAPServer() {
		static $CACHE;

		if (! isset($CACHE[$this->index]))
			$CACHE[$this->index] = $_SESSION[APPCONFIG]->ldapservers->Instance($this->index);

		return $CACHE[$this->index];
	}

	/**************************/
	/* Paint an Entry         */
	/**************************/

	public function visitEntryStart($entry) {
		if (DEBUG_ENABLED)
			debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$entry->getDn());

		// init
		$this->init('Visit', $entry);
	}

	public function visitEntryEnd($entry) {
		if (DEBUG_ENABLED)
			debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$entry->getDn());
	}

	protected function initEntryVisit($entry) {
		$this->internal_attributes = array();
		$this->shown_attributes = array();
		$this->hidden_attributes = array();
	}

	/********************************/
	/* Paint a DefaultCreatingEntry */
	/********************************/

	protected function initDefaultCreatingEntryVisit($entry) {
		$this->context = ENTRY_WRITER_CREATION_CONTEXT;
		$this->init('Entry::Visit', $entry);
	}

	/*******************************/
	/* Paint a DefaultEditingEntry */
	/*******************************/

	protected function initDefaultEditingEntryVisit($entry) {
		$this->context = ENTRY_WRITER_EDITING_CONTEXT;
		$this->init('Entry::Visit', $entry);
	}

	/*********************************/
	/* Paint a TemplateCreatingEntry */
	/*********************************/

	/********************************/
	/* Paint a TemplateEditingEntry */
	/********************************/

	/**************************/
	/* Paint an Attribute     */
	/**************************/

	public function visitAttribute($attribute) {
		if (DEBUG_ENABLED)
			debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$attribute->getName(),$this->visit_attributes);

		if (!$this->visit_attributes) return;

		if ($attribute->isInternal()) $this->internal_attributes[] = $attribute;
		elseif ($attribute->isVisible()) $this->shown_attributes[] = $attribute;
		else $this->hidden_attributes[] = $attribute;
	}
}

?>