parent_conf; } function user() { return $this->user; } function __construct($file_conf) { $this->req = $file_conf->req; $this->doc = $file_conf; $this->me = $this; $this->parent_conf = NULL; $this->log = DEFAULT_LOG_LIMIT; $this->register_default_users(); } function __clone() { $this->parent_conf = $this->me; $this->me = $this; $this->once_attrs = array(); $this->once_orig_attrs = array(); $this->undo_elm = NULL; } function pre_destruct() { # destruct self-references to allow garbage collecting and destruction $this->me = NULL; } function modified_now() { $this->doc->modified_now(); } function notice_html_ns($element) { if ($this->html_ns === NULL) { if ($element->namespaceURI === XHTML_NS) { $this->html_ns = XHTML_NS; } } } # Remember 'interesting' elements of output tree. function notice_out_element($element) { if ($element->namespaceURI === $this->html_ns) { $this->req->notice_out_html_element($element, $this->html_ns); } } function store_undo_data($undo_elm) { $this->undo_elm = $undo_elm; $this->undo_doc_modification_time = $this->doc->last_modification_time(); $this->undo_req_modification_time = $this->req->last_modification_time(); $this->undo_is_modified = $this->doc->is_modified; } function revert_undo_data() { if ($this->undo_elm !== NULL) { $this->doc->set_last_modification_time($this->undo_doc_modification_time); $this->req->set_last_modification_time($this->undo_req_modification_time); $this->doc->is_modified = $this->undo_is_modified; } return $this->undo_elm; } function set_base($uri_str) { if ($uri_str === '') { $this->base = NULL; } else { $uri = parse_w2ml_uri($uri_str); if ($uri === FALSE) { log_error('Invalid base URI "'.$uri_str.'"', $this->log); } elseif ($uri['scheme'] === NULL) { log_error('Partial base URI "'.$uri_str.'"', $this->log); } else { $this->base = $uri; } } } function doc_base() { $base = $this->base !== NULL ? $this->base : $this->doc->uri(); $base['path'] = base_uri_path($base['path']); return $base; } function work_directory() { $base = $this->doc_base(); switch ($base['scheme']) { case 'site': return site_uri_to_path($base); case 'file': return $base['path']; default: return REAL_W2ML_DOC_ROOT; } } private function register_default_users() { foreach (User::$default_users as $user_name) { $this->registered_users[$user_name] = new User($user_name); } } function log_default_user($name) { $this->user = $this->registered_users[$name]; } function log_user() { $logout = get_http_parameter('w2mllog'); if ($logout === 'out') { $this->user = $this->registered_users['w2mllogout']; return; } $name = get_http_parameter('w2mlusr'); if ($name === NULL) { $this->user = $this->registered_users['w2mlanon']; return; } if (in_array($name, User::$default_users, TRUE)) { $this->user = $this->registered_users['w2mlwrong']; return; } $password = get_http_parameter('w2mlpwd'); $this->user = $this->registered_users[$name]; if ($this->user === NULL) { $this->user = $this->registered_users['w2mlunknown']; } elseif ($this->user->password !== NULL && $this->user->password !== $password) { $this->user = $this->registered_users['w2mlnopwd']; } } } ?>