<?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
 */

/**#@+
 * required includes
 */
include_once('classes/core/Site.class.php');
include_once('classes/core/forms/PublicationForm.class.php');
include_once('classes/core/forms/EditionForm.class.php');
/**#@-*/

/**
 * Version Edition Form
 *
 * Allows granted user to modify existing permissions and
 * to add or remove groups and users
 *
 * @author     vinadelmar <vinadelmar@users.sourceforge.net>
 * @since      2006-04-25
 * @version    1.0.0
 * @package    Core
 * @subpackage Forms
 */
class PublicationEditionForm extends EditionForm {

	var $subObject;
	var $subObjectManager;

	/**
	 * Constructor
	 *
	 * @access public
	 * @param object $acl
	 * @param string $mode
	 */
	function PublicationEditionForm(&$version, &$versionManager, &$subObject, &$subObjectManager) {
		parent::EditionForm($version, $versionManager);
		$this->subObject = &$subObject;
		$this->subObjectManager = &$subObjectManager;
	}

	function populateUIContainer(&$guiContainer, $currLangId, $action) {
		$published = (bool) $this->subObject->isPublished();

		if($published) {
			$statusString = LANG_PUBLISHED_MESSAGE;
		}
		else {
			$statusString = LANG_NOT_PUBLISHED_MESSAGE;
		}

    $statusText = &new egStatic("st_status_text", $statusString, 10, 30, 350, 0, true);
    $publishComment = &new egStatic("st_publish_comment", LANG_PUBLISH_COMMENT, 10, 150, 400, 0);

    $publishStatusComment = &new egStatic("st_status_publish_comment", LANG_PUBLISH_STATUS_MESSAGE, 10, 70, 330, 0);
		$checkBox = &new egCheckBox("ckb_1", '<b>'.LANG_PUBLISH_TEXT.'</b>', 350, 70, 30, null, 'published', 1, $published);

		$guiContainer->addObject($statusText);
		$guiContainer->addObject($publishComment);
		$guiContainer->addObject($publishStatusComment);
		$guiContainer->addObject($checkBox);

		$script = "";

		if(!$published) {
			$script = "
function validationFunction() {
if(checkBox_ckb_1.checked) {
	return window.confirm('".LANG_PUBLISH_CONFIRM_MESSAGE."');
}
return true;
}
";
		}
    return $script;
	}

}

?>