<?php
/*
 * This file is part of the easy-CMS project.
 * easy-CMS 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.
 *
 * easy-CMS 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with easy-CMS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/**
 * @package    Core
 * @subpackage Forms
 */

/**
 */
include_once('classes/core/Site.class.php');

include_once('interface/egScript.class.php');
include_once('interface/egManager.class.php');
include_once('interface/egContainer.class.php');
include_once('interface/egMenuItem.class.php');
include_once('interface/egFrame.class.php');
include_once('interface/egToolTip.class.php');
include_once('interface/egRichText.class.php');
include_once('interface/egLink.class.php');
include_once('interface/egStatic.class.php');
include_once('interface/egEdit.class.php');
include_once('interface/egCheckBox.class.php');
include_once('interface/egRadioButton.class.php');
include_once('interface/egPressButton.class.php');
include_once('interface/egDropDownListBox.class.php');
include_once('interface/egPropertyList.class.php');
include_once('interface/egPropertySheet.class.php');
include_once('interface/egPropertyPage.class.php');

include_once('classes/core/forms/ACLEditionForm.class.php');
include_once('classes/core/forms/PublicationEditionForm.class.php');
include_once('classes/core/forms/VersionEditionForm.class.php');
include_once('classes/core/forms/ContentEditionForm.class.php');
include_once('classes/core/forms/ContainerEditionForm.class.php');
include_once('classes/core/forms/ContainersListEditionForm.class.php');
include_once('classes/core/forms/MenuEditionForm.class.php');
include_once('classes/core/forms/PageEditionForm.class.php');
include_once('classes/core/forms/UserEditionForm.class.php');
include_once('classes/core/forms/GroupEditionForm.class.php');


/**
 * Manage and instanciate EditionForms objects.
 *
 * @access     public
 * @author	   Cedric Francoys <cedric.francoys@easy-cms.org>
 * @version    FormsManager.class,v 0.1
 * @package	   Core
 * @subpackage Pages
 */
class FormsManager extends CoreObject {

	var $site;

	function FormsManager(&$site) {
		$this->site = &$site;
	}

  function getFormHTML($display, $mode) {
		$paneWidth  = 515;
		$paneHeight = 500;
		$windowTitle = 'easy-CMS edition form';
		$mainTitle  = LANG_GENERAL_TAB;
		$error = 0;

		$manager = &egManager::getInstance($windowTitle);

		// container has height = 1 and width = 1 to prevent covering other containers
		$hiddenValuesContainer = &new egContainer("ctn_hidden_values", 0, 0, 1, 1);

		$manager->addContainer($hiddenValuesContainer);

		switch($display) {
			case EDIT_CONTENT :
				$objectForm = &new ContentForm($this->site);

				if ($objectForm->getAction() == MODIF_CONTENT || $objectForm->getAction() == DELETE_CONTENT) {
					$scripts = new egScript();
          $line ="
            if(window.opener.opener != null) {
              window.opener.opener.location.reload();
              if(typeof(window.opener)!='undefined') {
                window.opener.close();
              }
            }
            else {
              if(window.opener != null) {
      		    	window.opener.location.reload();
              }
            }
      			window.close();";

					$scripts->addLine($line);
					$manager->addScripts($scripts);
				}
				if($objectForm->getAction() != DELETE_CONTENT) {
					if(!($content = &$objectForm->getObject())) {
						die('object no longer exists');
					}
					$objectEditForm = &new ContentEditionForm($objectForm->getObject(), $objectForm->getObjectManager());
					$contentId = $content->getContentId();
					$contentType = $content->getContentTypeName();

					$aclForm = &new ACLForm($this->site);
					$publicationForm = &new PublicationForm($this->site);

					if($objectForm->getAction() == ASK_MODIF_CONTENT) {
						$aclEditForm = &new ACLEditionForm($aclForm->getObject(), $aclForm->getObjectManager(), $this->site->getUsersManager(), $this->site->getGroupsManager());
						$publicationEditForm = &new PublicationEditionForm($publicationForm->getObject(), $publicationForm->getObjectManager(), $objectForm->getObject(), $objectForm->getObjectManager());

						if($contentId) {
							$versionForm = &new VersionForm($this->site);
							$versionEditForm = &new VersionEditionForm($versionForm->getObject(), $versionForm->getObjectManager(), $objectForm->getObject(), $objectForm->getObjectManager());
						}

						$objContainerId = &new egEdit("hidden_control_container_id", $objectForm->containerId, 0, 0, 0, 0, "container_id");
						$objContentId = &new egEdit("hidden_control_content_id", $objectForm->contentId, 0, 0, 0, 0, "content_id");
						$objTypeName = &new egEdit("hidden_control_type_name", $objectForm->contentType, 0, 0, 0, 0, "type_name");
						$objListId = &new egEdit("hidden_control_ml_id", $objectForm->mailingListId, 0, 0, 0, 0, "list_id");
						$objAclId = &new egEdit("hidden_control_acl_id", $aclForm->object->getAclId(), 0, 0, 0, 0, "acl_id");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_CONTENT, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", MODIF_CONTENT, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objContainerId);
						$hiddenValuesContainer->addObject($objContentId);
						$hiddenValuesContainer->addObject($objTypeName);
						$hiddenValuesContainer->addObject($objListId);
						$hiddenValuesContainer->addObject($objAclId);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
					else if ($objectForm->getAction() == ASK_DELETE_CONTENT) {
						if(!($content = &$objectForm->getObject())) {
							die('object no longer exists');
						}
						$acl = &$content->getContentAcl();
						$user = &$this->site->getCurrentUser();

						if(!$acl->userHasRemoveRight($user)) {
							$error = 1;
						}

						$paneWidth = 350;
						$paneHeight = 200;
						$mainTitle = LANG_DELETE_TAB;

						$objContentId = &new egEdit("hidden_control_content_id", $objectForm->contentId, 0, 0, 0, 0, "content_id");
						$objTypeName = &new egEdit("hidden_control_type_name", $objectForm->contentType, 0, 0, 0, 0, "type_name");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_CONTENT, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", DELETE_CONTENT, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objContentId);
						$hiddenValuesContainer->addObject($objTypeName);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
				}
				break;
			case EDIT_CONTAINER :
				$objectForm = &new ContainerForm($this->site);

				if ($objectForm->getAction() == MODIF_CONTAINER  || $objectForm->getAction() == DELETE_CONTAINER) {
					$scripts = new egScript();
					$line = "
            if(window.opener!= null) {
     		    	window.opener.location.reload();
            }
      			window.close();";
					$scripts->addLine($line);
					$manager->addScripts($scripts);
				}
				if ($objectForm->getAction() != DELETE_CONTAINER && $objectForm->getAction() != MOVE_CONTENT_UP && $objectForm->getAction() != MOVE_CONTENT_DOWN) {
					if(!($container = &$objectForm->getObject())) {
						die('object no longer exists');
					}
					$objectEditForm = &new ContainerEditionForm($objectForm->getObject(), $objectForm->getObjectManager());
					$aclForm = &new ACLForm($this->site);
					$publicationForm = &new PublicationForm($this->site);

					if($objectForm->getAction() == ASK_MODIF_CONTAINER) {
						$aclEditForm = &new ACLEditionForm($aclForm->getObject(), $aclForm->getObjectManager(), $this->site->getUsersManager(), $this->site->getGroupsManager());
						$publicationEditForm = &new PublicationEditionForm($publicationForm->getObject(), $publicationForm->getObjectManager(), $objectForm->getObject(), $objectForm->getObjectManager());

						$objContainerId = &new egEdit("hidden_control_container_id", $objectForm->containerId, 0, 0, 0, 0, "container_id");
						$objPageId = &new egEdit("hidden_control_page_id", $objectForm->pageId, 0, 0, 0, 0, "page_id");
						$objContainersListId = &new egEdit("hidden_control_ctnlist_id", $objectForm->containersListId, 0, 0, 0, 0, "containers_list_id");
						$objAclId = &new egEdit("hidden_control_acl_id", $aclForm->object->getAclId(), 0, 0, 0, 0, "acl_id");
						$objContainerType = &new egEdit("hidden_control_container_type", $objectForm->containerType, 0, 0, 0, 0, "container_type");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_CONTAINER, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", MODIF_CONTAINER, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objContainerType);
						$hiddenValuesContainer->addObject($objContainerId);
						$hiddenValuesContainer->addObject($objPageId);
						$hiddenValuesContainer->addObject($objContainersListId);
						$hiddenValuesContainer->addObject($objAclId);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
					else if ($objectForm->getAction() == ASK_DELETE_CONTAINER) {
						if(!($container = &$objectForm->getObject())) {
							die('object no longer exists');
						}
						$acl = &$container->getContainerAcl();
						$user = &$this->site->getCurrentUser();

						if(!$acl->userHasRemoveRight($user)) {
							$error = 1;
						}

						$paneWidth = 350;
						$paneHeight = 200;
						$mainTitle = LANG_DELETE_TAB;

						$objContainerId = &new egEdit("hidden_control_container_id", $objectForm->containerId, 0, 0, 0, 0, "container_id");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_CONTAINER, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", DELETE_CONTAINER, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objContainerId);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
				}
				break;
			case EDIT_MENU :
				$objectForm = &new MenuForm($this->site);

				if ($objectForm->getAction() == MODIF_MENU  || $objectForm->getAction() == DELETE_MENU) {
					$scripts = new egScript();
					$line = "
            if(window.opener!= null) {
     		    	window.opener.location.reload();
            }
      			window.close();";
					$scripts->addLine($line);
					$manager->addScripts($scripts);
				}
				if($objectForm->getAction() != DELETE_MENU && $objectForm->getAction() != MOVE_PAGE_UP && $objectForm->getAction() != MOVE_PAGE_DOWN) {
					if(!($menu = &$objectForm->getObject())) {
						die('object no longer exists');
					}

					$objectEditForm = &new MenuEditionForm($objectForm->getObject(), $objectForm->getObjectManager());

					$aclForm = &new ACLForm($this->site);
					$publicationForm = &new PublicationForm($this->site);

					if($objectForm->getAction() == ASK_MODIF_MENU) {
						$aclEditForm = &new ACLEditionForm($aclForm->getObject(), $aclForm->getObjectManager(), $this->site->getUsersManager(), $this->site->getGroupsManager());
						$publicationEditForm = &new PublicationEditionForm($publicationForm->getObject(), $publicationForm->getObjectManager(), $objectForm->getObject(), $objectForm->getObjectManager());

						$objMenuId = &new egEdit("hidden_control_menu_id", $objectForm->menuId, 0, 0, 0, 0, "menu_id");
						$objPageId = &new egEdit("hidden_control_page_id", $objectForm->pageId, 0, 0, 0, 0, "page_id");
						$objAclId = &new egEdit("hidden_control_acl_id", $aclForm->object->getAclId(), 0, 0, 0, 0, "acl_id");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_MENU, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", MODIF_MENU, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objMenuId);
						$hiddenValuesContainer->addObject($objPageId);
						$hiddenValuesContainer->addObject($objAclId);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
					else if ($objectForm->getAction() == ASK_DELETE_MENU) {
						if(!($menu = &$objectForm->getObject())) {
							die('object no longer exists');
						}

						$paneWidth = 350;
						$paneHeight = 200;
						$mainTitle = LANG_DELETE_TAB;

						$objMenuId = &new egEdit("hidden_control_container_id", $objectForm->menuId, 0, 0, 0, 0, "container_id");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_MENU, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", DELETE_MENU, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objMenuId);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
				}
				break;
			case EDIT_CONTAINERS_LIST :
				$objectForm = &new ContainersListForm($this->site);

				if ($objectForm->getAction() == MODIF_CONTAINERS_LIST) {
					$scripts = new egScript();
					$line = "
            if(window.opener!= null) {
     		    	window.opener.location.reload();
            }
      			window.close();";
					$scripts->addLine($line);
					$manager->addScripts($scripts);
				}
				if ($objectForm->getAction() != MOVE_CONTAINER_UP && $objectForm->getAction() != MOVE_CONTAINER_DOWN) {
					if(!($containersList = &$objectForm->getObject())) {
						die('object no longer exists');
					}
					$objectEditForm = &new ContainersListEditionForm($objectForm->getObject(), $objectForm->getObjectManager());

          $aclForm = &new ACLForm($this->site);
          $aclEditForm = &new ACLEditionForm($aclForm->getObject(), $aclForm->getObjectManager(), $this->site->getUsersManager(), $this->site->getGroupsManager());

					$publicationForm = &new PublicationForm($this->site);
					$publicationEditForm = &new PublicationEditionForm($publicationForm->getObject(), $publicationForm->getObjectManager(), $objectForm->getObject(), $objectForm->getObjectManager());

					$objPageId = &new egEdit("hidden_control_page_id", $objectForm->pageId, 0, 0, 0, 0, "page_id");
					$objAclId = &new egEdit("hidden_control_acl_id", $aclForm->object->getAclId(), 0, 0, 0, 0, "acl_id");
					$objDisplay = &new egEdit("hidden_control_display", EDIT_CONTAINERS_LIST, 0, 0, 0, 0, "display");
					$objMode = &new egEdit("hidden_control_mode", MODIF_CONTAINERS_LIST, 0, 0, 0, 0, "mode");

					$hiddenValuesContainer->addObject($objPageId);
					$hiddenValuesContainer->addObject($objAclId);
					$hiddenValuesContainer->addObject($objDisplay);
					$hiddenValuesContainer->addObject($objMode);
				}
				break;
			case EDIT_PAGE :
				$objectForm = &new PageForm($this->site);

				if ($objectForm->getAction() == MODIF_PAGE || $objectForm->getAction() == DELETE_PAGE) {
					$scripts = new egScript();
					$line = "
            if(window.opener!= null) {
     		    	window.opener.location.reload();
            }
      			window.close();";
					$scripts->addLine($line);
					$manager->addScripts($scripts);
				}
				if ($objectForm->getAction() != DELETE_PAGE && $objectForm->getAction() != MOVE_PAGE_UP && $objectForm->getAction() != MOVE_PAGE_DOWN) {
					if(!($page = &$objectForm->getObject())) {
						die('object no longer exists');
					}

					$objectEditForm = &new PageEditionForm($objectForm->getObject(), $objectForm->getObjectManager());
	    		$aclForm = &new ACLForm($this->site);
					$publicationForm = &new PublicationForm($this->site);

					if($objectForm->getAction() == ASK_MODIF_PAGE) {

    				$aclEditForm = &new ACLEditionForm($aclForm->getObject(), $aclForm->getObjectManager(), $this->site->getUsersManager(), $this->site->getGroupsManager());
						$publicationEditForm = &new PublicationEditionForm($publicationForm->getObject(), $publicationForm->getObjectManager(), $objectForm->getObject(), $objectForm->getObjectManager());

  					$objPageId = &new egEdit("hidden_control_page_id", $objectForm->pageId, 0, 0, 0, 0, "page_id");
  					$objAclId = &new egEdit("hidden_control_acl_id", $aclForm->object->getAclId(), 0, 0, 0, 0, "acl_id");
  					$objDisplay = &new egEdit("hidden_control_display", EDIT_PAGE, 0, 0, 0, 0, "display");
  					$objMode = &new egEdit("hidden_control_mode", MODIF_PAGE, 0, 0, 0, 0, "mode");

						if($objectForm->parentId > 0) {
	  					$objParentId = &new egEdit("hidden_control_parent_id", $objectForm->parentId, 0, 0, 0, 0, "parent_id");
  						$hiddenValuesContainer->addObject($objParentId);
						}

  					$hiddenValuesContainer->addObject($objPageId);
  					$hiddenValuesContainer->addObject($objAclId);
  					$hiddenValuesContainer->addObject($objDisplay);
  					$hiddenValuesContainer->addObject($objMode);
          }
					else if ($objectForm->getAction() == ASK_DELETE_PAGE) {
						if(!($page = &$objectForm->getObject())) {
							die('object no longer exists');
						}
						$acl = &$page->getPageAcl();
						$user = &$this->site->getCurrentUser();

						if(!$acl->userHasRemoveRight($user)) {
							$error = 1;
						}

						$paneWidth = 350;
						$paneHeight = 200;
						$mainTitle = LANG_DELETE_TAB;

  					$objPageId = &new egEdit("hidden_control_page_id", $objectForm->pageId, 0, 0, 0, 0, "page_id");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_PAGE, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", DELETE_PAGE, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objPageId);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
        }
				break;
			case EDIT_USER :
				$objectForm = &new UserForm($this->site);

				if ($objectForm->getAction() == MODIF_USER || $objectForm->getAction() == DELETE_USER) {
					$scripts = new egScript();
					$line = "
            if(window.opener!= null) {
     		    	window.opener.location.reload();
            }
      			window.close();";
					$scripts->addLine($line);
					$manager->addScripts($scripts);
				}
				if ($objectForm->getAction() != DELETE_USER) {
					if(!($user = &$objectForm->getObject())) {
						die('object no longer exists');
					}

					$objectEditForm = &new UserEditionForm($objectForm->getObject(), $objectForm->getObjectManager());

					if($objectForm->getAction() == ASK_MODIF_USER) {

  					$objUserId = &new egEdit("hidden_control_user_id", $objectForm->userId, 0, 0, 0, 0, "user_id");
  					$objDisplay = &new egEdit("hidden_control_display", EDIT_USER, 0, 0, 0, 0, "display");
  					$objMode = &new egEdit("hidden_control_mode", MODIF_USER, 0, 0, 0, 0, "mode");

  					$hiddenValuesContainer->addObject($objUserId);
  					$hiddenValuesContainer->addObject($objDisplay);
  					$hiddenValuesContainer->addObject($objMode);
          }
					else if ($objectForm->getAction() == ASK_DELETE_USER) {
						if(!($user = &$objectForm->getObject())) {
							die('object no longer exists');
						}

						$paneWidth = 350;
						$paneHeight = 200;
						$mainTitle = LANG_DELETE_TAB;

  					$objUserId = &new egEdit("hidden_control_user_id", $objectForm->userId, 0, 0, 0, 0, "user_id");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_USER, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", DELETE_USER, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objUserId);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
        }
				break;
			case EDIT_GROUP :
				$objectForm = &new GroupForm($this->site);

				if ($objectForm->getAction() == MODIF_GROUP || $objectForm->getAction() == DELETE_GROUP) {
					$scripts = new egScript();
					$line = "
            if(window.opener!= null) {
     		    	window.opener.location.reload();
            }
      			window.close();";
					$scripts->addLine($line);
					$manager->addScripts($scripts);
				}
				if ($objectForm->getAction() != DELETE_GROUP) {
					if(!($group = &$objectForm->getObject())) {
							die('object no longer exists');
					}
					$objectEditForm = &new GroupEditionForm($objectForm->getObject(), $objectForm->getObjectManager());

					if($objectForm->getAction() == ASK_MODIF_GROUP) {

  					$objGroupId = &new egEdit("hidden_control_group_id", $objectForm->groupId, 0, 0, 0, 0, "group_id");
  					$objDisplay = &new egEdit("hidden_control_display", EDIT_GROUP, 0, 0, 0, 0, "display");
  					$objMode = &new egEdit("hidden_control_mode", MODIF_GROUP, 0, 0, 0, 0, "mode");

  					$hiddenValuesContainer->addObject($objGroupId);
  					$hiddenValuesContainer->addObject($objAclId);
  					$hiddenValuesContainer->addObject($objDisplay);
  					$hiddenValuesContainer->addObject($objMode);
          }
					else if ($objectForm->getAction() == ASK_DELETE_GROUP) {
						if(!($group = &$objectForm->getObject())) {
								die('object no longer exists');
						}

						$paneWidth = 350;
						$paneHeight = 200;
						$mainTitle = LANG_DELETE_TAB;

  					$objGroupId = &new egEdit("hidden_control_group_id", $objectForm->groupId, 0, 0, 0, 0, "group_id");
						$objDisplay = &new egEdit("hidden_control_display", EDIT_GROUP, 0, 0, 0, 0, "display");
						$objMode = &new egEdit("hidden_control_mode", DELETE_GROUP, 0, 0, 0, 0, "mode");

						$hiddenValuesContainer->addObject($objGroupId);
						$hiddenValuesContainer->addObject($objDisplay);
						$hiddenValuesContainer->addObject($objMode);
					}
        }
				break;
			case EDIT_VERSION :
				$contentForm = &new ContentForm($this->site);
				$objectForm = &new VersionForm($this->site);
				$objectEditForm = &new VersionEditionForm($objectForm->getObject(), $objectForm->getObjectManager(), $contentForm->getObject(), $contentForm->getObjectManager());

				$objDisplay = &new egEdit("hidden_control_display", EDIT_CONTENT, 0, 0, 0, 0, "display");
				$objMode = &new egEdit("hidden_control_mode", MODIF_CONTENT, 0, 0, 0, 0, "mode");

				$hiddenValuesContainer->addObject($objDisplay);
				$hiddenValuesContainer->addObject($objMode);
				break;
			default:
				// error : unrecognized display type
				break;
		}

		if(ENABLE_SECURITY && isset($aclForm) && is_object($aclForm)){
			$newAclId = $aclForm->processForm();
		}

		if(ENABLE_VERSIONING && isset($versionForm) && is_object($versionForm)){
			$versionForm->processForm();
		}

		if(isset($objectForm) && is_object($objectForm)){
			$objectForm->processForm();
      if(isset($newAclId) && $newAclId > 0) {
				$objectForm->spreadAcl($newAclId);
			}
		}

		$view_deleted = $this->site->getSubmittedVar('deleted', false);

		if(!$error && $view_deleted === false) {
			$okButton = &new egPressbutton("btn_1", LANG_OK_BUTTON, $paneWidth-150, $paneHeight+50, 80, null, "clickOKButton();");
		}
		$cancelButton = &new egPressbutton("btn_2", LANG_CANCEL_BUTTON, $paneWidth-65, $paneHeight+50, 80, null, "clickCancelButton();");

		$propertySheet = &new egPropertySheet("pts_1", "Menu", 10, 10, $paneWidth, $paneHeight);

		if(isset($objectEditForm) && is_object($objectEditForm)){
			$editContainer = &new egContainer("ctn_edit", 5, 5, $paneWidth-5, $paneHeight-5);
			$line = $objectEditForm->populateUIContainer($editContainer, $objectForm->getLangId(), $objectForm->getAction(), $error);
			$scripts = &new egScript();
			$scripts->addLine($line);
			$manager->addScripts($scripts);
      $propertySheet->addPage(new egPropertyPage("ptp_1", $mainTitle, $editContainer->getContainerName()));
      $propertySheet->addContainer($editContainer);
		}

		if(ENABLE_SECURITY && isset($aclEditForm) && is_object($aclEditForm)){
			$rightsContainer = &new egContainer("ctn_rights", 5, 5, $paneWidth-5, $paneHeight-5);
			$line = $aclEditForm->populateUIContainer($rightsContainer, $aclForm->getParentObjAclId());
			$scripts = &new egScript();
			$scripts->addLine($line);
			$manager->addScripts($scripts);
      $propertySheet->addPage(new egPropertyPage("ptp_2", LANG_SECURITY_TAB, $rightsContainer->getContainerName()));
      $propertySheet->addContainer($rightsContainer);
		}

		if(ENABLE_VERSIONING && isset($versionEditForm) && is_object($versionEditForm)){
			$versionsContainer = &new egContainer("ctn_versions", 5, 5, $paneWidth-5, $paneHeight-5);
			$line = $versionEditForm->populateUIContainer($versionsContainer, $objectForm->getLangId(), $objectForm->getAction());
			$scripts = &new egScript();
			$scripts->addLine($line);
			$manager->addScripts($scripts);
      $propertySheet->addPage(new egPropertyPage("ptp_3", LANG_VERSIONING_TAB, $versionsContainer->getContainerName()));
  		$propertySheet->addContainer($versionsContainer);
		}

		if(ENABLE_PUBLICATION && isset($publicationEditForm) && is_object($publicationEditForm)){
			$publicationContainer = &new egContainer("ctn_publication", 5, 5, $paneWidth-5, $paneHeight-5);
			$line = $publicationEditForm->populateUIContainer($publicationContainer, $objectForm->getLangId(), $objectForm->getAction());
			$scripts = &new egScript();
			$scripts->addLine($line);
			$manager->addScripts($scripts);
      $propertySheet->addPage(new egPropertyPage("ptp_4", LANG_PUBLISHING_TAB, $publicationContainer->getContainerName()));
  		$propertySheet->addContainer($publicationContainer);
		}

		$main = &new egContainer("main_ctn", 3, 0, 1024, 768);
		$scripts = &new egScript();
		$line = "
function clickOKButton() {
	if(typeof(window['validationFunction']) == 'undefined') {
		document.forms[0].submit();
	}
	else {
		if(validationFunction()){
			document.forms[0].submit();
		}
	}
}
function clickCancelButton() {
	window.close();
}
";
		$scripts->addLine($line);

		$main->addObject($okButton);
		$main->addObject($cancelButton);
		$main->addObject($propertySheet);

		$manager->addScripts($scripts);
		$manager->addContainer($main);

		return $manager->getHTML();
	}

}
?>